Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int n, n13=0, nn=0, nw13=0, nwn=0, ans=0;
  7.     int w[4];
  8.     cin>>n;
  9.     for(int i=0;i<4;i++){
  10.         cin>>w[i];
  11.         if(w[i]%13==0){
  12.             n13+=1;
  13.             nw13+=1;
  14.         }
  15.         else{
  16.             nn++;
  17.             nwn++;
  18.         }
  19.     }
  20.    
  21.     for(int e=0;e<n-4;e++){
  22.         int a; cin>>a;
  23.         if(a%13==0){
  24.             ans+=(n13+nn-nw13-nwn);
  25.             n13++;
  26.             nw13++;
  27.         }
  28.         else{
  29.             ans+=(n13-nw13);
  30.             nn++;
  31.             nwn++;
  32.         }
  33.         if(w[0]%13==0)
  34.         {
  35.             nw13--;
  36.         }
  37.         else
  38.         {
  39.             nwn--;
  40.         }
  41.         for(int i=1; i<4; i++)
  42.         {
  43.             w[i-1]=w[i];
  44.         }
  45.         w[3]=a;
  46.        
  47.     }
  48.     cout<<ans<<endl;
  49.     // 0 <- 1 <- 2 <- 3
  50.     //                        !a
  51.     // 12 312 4 {23 [{34 12 13} 12}] 34 4 3 2
  52.     //  n_13, n_n, n_w13, n_wn, w1, w2, w3, w4
  53.    
  54.     //vector<int> mass(n);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement