#include <vector> #include <cstdio> using namespace std; int main() { vector<int> s(20); for (int a = 0; a < 10; a++) for (int b = 0; b < 10; b++) s[a+b]++; char n[23]; scanf("%s",n); vector<long long> ret(23); ret[0] = 1; for (int i = 0; ; i++) { if (!n[i]) { printf("%lld\n", ret[i]); break; } ret[i+1] += ret[i] * s[n[i] - '0']; if (n[i] == '1' && n[i+1]) { ret[i+2] += ret[i] * s[10 + n[i+1]-'0']; } } 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 | #include <vector> #include <cstdio> using namespace std; int main() { vector<int> s(20); for (int a = 0; a < 10; a++) for (int b = 0; b < 10; b++) s[a+b]++; char n[23]; scanf("%s",n); vector<long long> ret(23); ret[0] = 1; for (int i = 0; ; i++) { if (!n[i]) { printf("%lld\n", ret[i]); break; } ret[i+1] += ret[i] * s[n[i] - '0']; if (n[i] == '1' && n[i+1]) { ret[i+2] += ret[i] * s[10 + n[i+1]-'0']; } } return 0; } |