Advertisement
Graf_Rav

Untitled

Jan 19th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. const int N=7;
  7.  
  8. int main(){
  9.     int n;
  10.     cin>>n;
  11.    
  12.     vector<int> ar(N, 0);
  13.    
  14.     for(int i=0;i<n;i++){
  15.         int a;
  16.         cin>>a;
  17.         ar[a%N]++;
  18.     }
  19.    
  20.     int ans=ar[0]*(ar[0]-1)/2;
  21.    
  22.     for(int i=1;i<(N+1)/2;i++){
  23.         ans+=ar[i]*ar[N-i];
  24.     }
  25.    
  26.     if(N%2==0){
  27.         ans+=ar[N/2]*(ar[N/2]-1)/2;
  28.     }
  29.    
  30.     cout<<ans;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement