#include <iostream>
#define T long long unsigned
T count(T x) {
T res;
if(x) {
res = (x % 10 + 1) * count(x / 10);
} else {
res = 1;
}
if(x % 100 > 9 && x % 100 < 19) {
res += (19 - x % 100) * count(x / 100);
}
return res;
}
int main() {
T n;
std::cin >> n;
std::cout << count(n) << std::endl;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> #define T long long unsigned T count(T x) { T res; if(x) { res = (x % 10 + 1) * count(x / 10); } else { res = 1; } if(x % 100 > 9 && x % 100 < 19) { res += (19 - x % 100) * count(x / 100); } return res; } int main() { T n; std::cin >> n; std::cout << count(n) << std::endl; } |
English