Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <vector>
- #include <conio.h>
- using namespace std;
- void debugPrint(short z);
- void countCalc(vector<int> input);
- void countCalc(vector<int> input1, vector<int> input2);
- vector<int> critNumbers[4];
- //0 = 1; 1 = 3; 2 = 7; 3 = 9;
- short n = 0;
- int mainCount = 0;
- int main()
- {
- cin >> n;
- for (int i = 0; i < n; i++) {
- int x = 0;
- cin >> x;
- x %= 10;
- switch (x)
- {
- case 1:
- critNumbers[0].push_back(i);
- break;
- case 3:
- critNumbers[1].push_back(i);
- break;
- case 7:
- critNumbers[2].push_back(i);
- break;
- case 9:
- critNumbers[3].push_back(i);
- break;
- }
- }
- countCalc(critNumbers[0]);
- countCalc(critNumbers[1], critNumbers[2]);
- countCalc(critNumbers[2], critNumbers[1]);
- countCalc(critNumbers[3]);
- cout << mainCount;
- _getch();
- return 0;
- }
- void countCalc(vector<int> input) {
- int lowBorder = 0;
- for (int i = 0; i < input.size(); i++) {
- if (lowBorder == 0) {
- lowBorder = i + 1;
- }
- int q = lowBorder;
- bool isntFound = true;
- while (q < input.size() && isntFound) {
- if (input[q] - input[i] - 1 >= 4) {
- mainCount += input.size() - q;
- lowBorder = q;
- isntFound = false;
- }
- q++;
- }
- }
- }
- void countCalc(vector<int> input1, vector<int> input2) {
- int lowBorder = 0;
- for (int i = 0; i < input1.size(); i++) {
- int q = lowBorder;
- bool isntFound = true;
- while (q < input2.size() && isntFound) {
- if (input2[q] - input1[i] - 1 >= 4) {
- mainCount += input2.size() - q;
- lowBorder = q;
- isntFound = false;
- }
- q++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement