Advertisement
ahamed210

Lucky tickets easy

Nov 10th, 2021
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.36 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef int l;
  4. typedef long long int ll;
  5. #define loop(a, b) for(int i = a; i < b; i++)
  6. #define PI acos(-1.0)
  7. const ll INF = LLONG_MAX;
  8.  
  9. const ll mod = 1000000007;
  10. ll gcd(ll a,ll b){ if(b == 0) return a; return gcd(b, a % b); }
  11.  ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  12. //ll power(ll a, ll b){ll res = 1;while(b){if(b&1) res = (res*a)%mod;b>>=1;a = (a*a)%mod;}return res%mod;}
  13. //leftmost set bit
  14. l clz(int N) {return N ? 32 - __builtin_clz(N) : -(1e9+1);}
  15. //ll clz(unsigned long long N){return N ? 64 - __builtin_clzll(N) : -(1e18+1);}
  16. ll setbit(ll x){return __builtin_popcountll(x);}
  17. ll power(ll a, ll b){ll res = 1;while(b){if(b&1) res = (res*a);b>>=1;a = (a*a);}return res;}
  18. bool arraySortedOrNot(int arr[], int n){if (n == 0 || n == 1) return true;for (int i = 1; i < n; i++)if (arr[i - 1] > arr[i]) return false;return true;}
  19. // long long v[400002];
  20. // void Quicksort(int begin,int end){
  21. //   int e,b,aux,p;b=begin;e=end;p=v[(e+b)/2];
  22. //   while(v[b]<p){b++;}while(v[e]>p){e--;}while(b<e){aux=v[b];v[b]=v[e];v[e]=aux;do{b++;}while(v[b]<p);
  23. //   do{e--;}while(v[e]>p);}if(begin<e){ Quicksort(begin,e);}
  24. //   if(e+1<end){ Quicksort(e+1,end);}
  25. // }
  26.  
  27. void run(){
  28.     ios::sync_with_stdio(false);
  29.     cin.tie(NULL);
  30.     cout.tie(NULL);
  31. #ifndef ONLINE_JUDGE
  32.     freopen("input.txt", "r", stdin);
  33.     freopen("output7.txt", "w", stdout);
  34. #else
  35. #endif
  36. }
  37.  
  38. l cnt[100];
  39. void solve(){
  40.     l x;cin>>x;
  41.     x = x >> 1;
  42.     x = power(10, x);
  43.     for(l i = 0; i < x; i++){
  44.         l y = i;
  45.         l sum = 0;
  46.         while(y > 0){
  47.             sum += (y%10);
  48.             y/=10;
  49.         }
  50.         cnt[sum] = cnt[sum] + 1;
  51.     }
  52.     l total = 0;
  53.     for(l i = 0; i < x; i++){
  54.         l y = i;
  55.         l sum = 0;
  56.         while(y > 0){
  57.             sum += (y%10);
  58.             y/=10;
  59.         }
  60.         total+=cnt[sum];
  61.     }
  62.     cout << total << endl;
  63.      
  64. }
  65.  
  66. int main()
  67. {
  68.     //clock_t tStart = clock();
  69.     ios::sync_with_stdio(false);
  70.     cin.tie(NULL);
  71.     cout.tie(NULL);
  72.     //run();
  73.     l n = 1;//cin>>n;
  74.     //dummy getline
  75.     //string s;getline(cin,s);
  76.     //char s[2100];
  77.     //while(cin>>s) {solve(s);}
  78.     while(n--){solve();}
  79.     //l n;
  80.     //while(cin>>n && n){solve(n);}
  81.     //cout << endl;
  82.     //printf("Time taken: %.10fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement