Advertisement
Asif_Anwar

Timus-1044. Lucky Tickets. Easy!

Apr 8th, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define pb push_back
  5. #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  6. #define F first
  7. #define S second
  8. typedef long long ll;
  9. typedef vector< int > vi;
  10. typedef vector< ll > V;
  11. typedef map<int, int > mp;
  12. #define debug cout << -1 << endl;
  13. #define REP(i, a, b) for(int i=a; i<b; i++)
  14. #define pop pop_back
  15. const ll MOD = 1000000007;
  16. const int maxN = 2001;
  17.  
  18. int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
  19. int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
  20.  
  21. void solve()
  22. {
  23.     int n;
  24.     cin >> n;
  25.     int cnt = 0;
  26.     if(n==2) {
  27.        
  28.         for(int a=0; a<=9; a++) {
  29.             for(int b=0; b<=9; b++) {
  30.                 if(a==b) cnt++;
  31.             }
  32.         }
  33.     }
  34.     else if(n==4){
  35.         for(int a=0; a<=9; a++) {
  36.             for(int b=0; b<=9; b++) {
  37.                 for(int c=0; c<=9; c++) {
  38.                     for(int d=0; d<=9; d++) {
  39.                         if(a+b==c+d) cnt++;
  40.                     }
  41.                 }
  42.             }
  43.         }
  44.     }
  45.     else if(n==6){
  46.         for(int a=0; a<=9; a++) {
  47.             for(int b=0; b<=9; b++) {
  48.                 for(int c=0; c<=9; c++) {
  49.                     for(int d=0; d<=9; d++) {
  50.                         for(int e=0; e<=9; e++) {
  51.                             for(int f=0; f<=9; f++) {
  52.                                 if(a+b+c==d+e+f) cnt++;
  53.                             }
  54.                         }
  55.                        
  56.                     }
  57.                 }
  58.             }
  59.         }
  60.     }
  61.     else if(n==8){
  62.         for(int a=0; a<=9; a++) {
  63.             for(int b=0; b<=9; b++) {
  64.                 for(int c=0; c<=9; c++) {
  65.                     for(int d=0; d<=9; d++) {
  66.                         for(int e=0; e<=9; e++) {
  67.                             for(int f=0; f<=9; f++) {
  68.                                 for(int g=0; g<=9; g++) {
  69.                                     for(int h=0; h<=9; h++) {
  70.                                         if(a+b+c+d==e+f+g+h) cnt++;
  71.                                     }
  72.                                 }
  73.                             }
  74.                         }
  75.                        
  76.                     }
  77.                 }
  78.             }
  79.         }
  80.     }
  81.     cout << cnt << endl;
  82.     return;
  83. }
  84.  
  85. int main()
  86. {
  87.     FastIO;
  88.     int t;
  89.     t = 1;
  90.     //cin >> t;
  91.     while(t--){
  92.         solve();
  93.     }
  94.     return 0;
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement