#include <cstdio> long long N; long long a, b, c, x, y; int main() { scanf("%lld", &N); a = 1; while (N > 0) { x = N % 10; c = a; a = (x + 1) * a + (x == 1 ? (9 - y) * b : 0); b = c; y = x; N = N / 10; } printf("%lld", a); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <cstdio> long long N; long long a, b, c, x, y; int main() { scanf("%lld", &N); a = 1; while (N > 0) { x = N % 10; c = a; a = (x + 1) * a + (x == 1 ? (9 - y) * b : 0); b = c; y = x; N = N / 10; } printf("%lld", a); return 0; } |