#include <iostream> using namespace std; long long solve(long long a){ if(a == 0)return 1; long long x = a % 10; long long ret = 0; ret = solve(a/10)*(x+1); x = a % 100; if(x!=(a%10) && x<19){ ret += solve(a/100)*(19-x); } return ret; } int main() { long long a; cin>>a; cout<<solve(a); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> using namespace std; long long solve(long long a){ if(a == 0)return 1; long long x = a % 10; long long ret = 0; ret = solve(a/10)*(x+1); x = a % 100; if(x!=(a%10) && x<19){ ret += solve(a/100)*(19-x); } return ret; } int main() { long long a; cin>>a; cout<<solve(a); } |