Advertisement
TheAnshul

winning lottery tickets

Jun 23rd, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********TheAnshul********/
  2. #include<bits/stdc++.h>
  3. #define ll          long long
  4. #define pb          push_back
  5. #define endl        '\n'
  6. #define pii         pair<ll int,ll int>
  7. #define vi          vector<ll int>
  8. #define all(a)      (a).begin(),(a).end()
  9. #define F           first
  10. #define S           second
  11. #define sz(x)       (ll int)x.size()
  12. #define hell        1000000007
  13. #define rep(i,a,b)  for(ll int i=a;i<b;i++)
  14. #define lbnd        lower_bound
  15. #define ubnd        upper_bound
  16. #define bs          binary_search
  17. #define mp          make_pair
  18. using namespace std;
  19. #define N  100005
  20.  
  21. int main()
  22. {
  23.     ios_base::sync_with_stdio(false);
  24.     cin.tie(0);
  25.     cout.tie(0);
  26.     int TESTS=1;
  27. //  cin>>TESTS;
  28.     while(TESTS--)
  29.     {
  30.         ll n,ans=0;
  31.         cin>>n;
  32.         // vector<int>p(n);
  33.         int pow[]={1,2,4,8,16,32,64,128,256,512};
  34.         string s;
  35.         vi p(1024,0);
  36.         rep(i,0,n)
  37.         {
  38.             vector<int>v(10,0);
  39.             int num=0;
  40.             cin>>s;
  41.             rep(j,0,s.length())
  42.             {
  43.                 v[s[j]-48]=1;
  44.             }
  45.             rep(j,0,10)
  46.             {
  47.                 if(v[j]==1)
  48.                     num+=pow[j];
  49.             }
  50.             // cout<<num<<endl;
  51.             p[num]++;
  52.         }
  53.         // for(map<ll,ll>:: iterator it=mp.begin();it!=mp.end();it++)
  54.         //  cout<<it->F<<" "<<it->S<<endl;
  55.         rep(i,0,1024)
  56.         {
  57.             rep(j,i+1,1024)
  58.             {
  59.                 if((j | i)==1023)
  60.                     ans+=p[i]*p[j];
  61.             }
  62.         }
  63.         ans+=p[1023]*(p[1023]-1);
  64.         cout<<ans;
  65.     }
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement