Advertisement
Graf_Rav

Untitled

May 17th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     queue<int> q;
  8.    
  9.     int n;
  10.     cin>>n;
  11.     for(int i=0;i<5;i++){
  12.         int a;
  13.         cin>>a;
  14.         q.push(a);
  15.     }
  16.    
  17.     int ch13=0;
  18.     int nech13=0;
  19.     int chN13=0;
  20.     int nechN13=0;
  21.    
  22.     int ans=0;
  23.     for(int i=5;i<n;i++){
  24.         int a;
  25.         cin>>a;
  26.         q.push(a);
  27.         if(q.front()%2==0){
  28.             if(q.front()%13==0){
  29.                 ch13++;
  30.             }
  31.             else{
  32.                 chN13++;
  33.             }
  34.         }
  35.         else{
  36.             if(q.front()%13==0){
  37.                 nech13++;
  38.             }
  39.             else{
  40.                 nechN13++;
  41.             }
  42.         }
  43.         if(q.back()%2==0){
  44.             if(q.back()%13==0){
  45.                 ans+=nechN13;
  46.             }
  47.             ans+=nech13;
  48.         }
  49.         else{
  50.             if(q.back()%13==0){
  51.                 ans+=chN13;
  52.             }
  53.             ans+=ch13;
  54.         }
  55.        
  56.         q.pop();
  57.     }
  58.    
  59.     cout<<ans;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement