#include <bits/stdc++.h> #define PB push_back #define ST first #define ND second #define _ ios_base::sync_with_stdio(0); cin.tie(0); //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; ll ans; void rec(ll x,vi v) { if(x==0) { ll w = 1; for(auto it:v) { if(it>9) w*=(19-it); else w*=(it+1); } ans+=w; } else { v.PB(x%10); rec(x/10,v); v.pop_back(); if(x%100>9&&x%100<19) { v.PB(x%100); rec(x/100,v); } } } int main() {_ ll n; cin>>n; rec(n,{}); cout<<ans; }
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 38 39 40 41 | #include <bits/stdc++.h> #define PB push_back #define ST first #define ND second #define _ ios_base::sync_with_stdio(0); cin.tie(0); //mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; ll ans; void rec(ll x,vi v) { if(x==0) { ll w = 1; for(auto it:v) { if(it>9) w*=(19-it); else w*=(it+1); } ans+=w; } else { v.PB(x%10); rec(x/10,v); v.pop_back(); if(x%100>9&&x%100<19) { v.PB(x%100); rec(x/100,v); } } } int main() {_ ll n; cin>>n; rec(n,{}); cout<<ans; } |