Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //10 1 2 3 4 13 15 18 19 26 26
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- const int sizeLast = 5;
- int lastInput[sizeLast] = { -1,-1,-1,-1,-1 };//последние 5 элементов // fisrt - делимость на 13; second - чётность
- int countPairs = 0;
- int main()
- {
- int n = 0;
- int input = 0;
- cin >> n;
- for (int i = 0; i < n; i++) {
- cin >> input;
- for (int q = 0; q < sizeLast - 1; q++) {
- lastInput[q] = lastInput[q + 1];
- }
- lastInput[sizeLast - 1] = input;
- for (int q = 0; q < sizeLast - 1; q++) {
- if (lastInput[q] != -1) {
- bool f = (lastInput[q] % 13 == 0 || lastInput[sizeLast - 1] % 13 == 0);
- bool s = (lastInput[q] % 2 != lastInput[sizeLast - 1] % 2)*(lastInput[q] % 2 == 0 || lastInput[sizeLast - 1] % 2 == 0);
- countPairs += f * s;
- }
- }
- }
- cout << countPairs;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement