// Karol Kosinski 2019 #include <cstdio> #define FOR(i,a,b) for(int i=(a);i<(b);++i) using namespace std; typedef unsigned long long LL; int H[100]; LL f(LL x) { if (x == 0) return 1; LL r = (x % 10 + 1) * f(x / 10); if (H[x % 100] == 0) return r; return r + H[x % 100] * f(x / 100); } int main() { LL n; FOR(i,10,19) H[i] = 19 - i; scanf("%lld", &n); printf("%lld\n", f(n)); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // Karol Kosinski 2019 #include <cstdio> #define FOR(i,a,b) for(int i=(a);i<(b);++i) using namespace std; typedef unsigned long long LL; int H[100]; LL f(LL x) { if (x == 0) return 1; LL r = (x % 10 + 1) * f(x / 10); if (H[x % 100] == 0) return r; return r + H[x % 100] * f(x / 100); } int main() { LL n; FOR(i,10,19) H[i] = 19 - i; scanf("%lld", &n); printf("%lld\n", f(n)); return 0; } |