#include <vector> #include <cstdio> #define ll long long using namespace std; int main(int argc, char** argv) { vector<ll> res; res.push_back(1); int prev = -1; for(;;) { int c = getchar(); if(c < '0' || c > '9') { break; } c -= '0'; ll next = res.back()*(c + 1); if(prev != -1) { int t = prev * 10 + c; if(t >= 10 && t <= 18) { next += (res.end()[-2])*(19 - t); } } res.push_back(next); prev = c; } printf("%lld\n", res.back()); 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 25 26 27 28 29 30 | #include <vector> #include <cstdio> #define ll long long using namespace std; int main(int argc, char** argv) { vector<ll> res; res.push_back(1); int prev = -1; for(;;) { int c = getchar(); if(c < '0' || c > '9') { break; } c -= '0'; ll next = res.back()*(c + 1); if(prev != -1) { int t = prev * 10 + c; if(t >= 10 && t <= 18) { next += (res.end()[-2])*(19 - t); } } res.push_back(next); prev = c; } printf("%lld\n", res.back()); return 0; } |