#include <iostream> using namespace std; typedef unsigned long long ull; int main() { ios_base::sync_with_stdio(0); ull sum; cin >> sum; int prevd = 0; int currd = 0; ull res = 1; ull pres = 0; ull sres = 0; while(sum){ prevd = currd; currd = sum % 10; sum /= 10; sres = pres; pres = res; res = pres * (currd + 1); if(currd == 1){ res += sres * (9 - prevd); } } cout << res << endl; 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 31 32 33 34 35 36 37 | #include <iostream> using namespace std; typedef unsigned long long ull; int main() { ios_base::sync_with_stdio(0); ull sum; cin >> sum; int prevd = 0; int currd = 0; ull res = 1; ull pres = 0; ull sres = 0; while(sum){ prevd = currd; currd = sum % 10; sum /= 10; sres = pres; pres = res; res = pres * (currd + 1); if(currd == 1){ res += sres * (9 - prevd); } } cout << res << endl; return 0; } |