Advertisement
ktagir

N27.82

Mar 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. //10 1 2 3 4 13 15 18 19 26 26
  2. #include "stdafx.h"
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. const int sizeLast = 5;
  8.  
  9. int lastInput[sizeLast] = { -1,-1,-1,-1,-1 };//последние 5 элементов // fisrt - делимость на 13; second - чётность
  10. int countPairs = 0;
  11.  
  12. int main()
  13. {
  14.     int n = 0;
  15.     int input = 0;
  16.     cin >> n;
  17.     for (int i = 0; i < n; i++) {
  18.         cin >> input;
  19.         for (int q = 0; q < sizeLast - 1; q++) {
  20.             lastInput[q] = lastInput[q + 1];
  21.         }
  22.         lastInput[sizeLast - 1] = input;
  23.         for (int q = 0; q < sizeLast - 1; q++) {
  24.             if (lastInput[q] != -1) {
  25.                 bool f = (lastInput[q] % 13 == 0 || lastInput[sizeLast - 1] % 13 == 0);
  26.                 bool s = (lastInput[q] % 2 != lastInput[sizeLast - 1] % 2)*(lastInput[q] % 2 == 0 || lastInput[sizeLast - 1] % 2 == 0);
  27.                 countPairs += f * s;
  28.             }
  29.         }
  30.     }
  31.     cout << countPairs;
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement