STANAANDREY

bacT9 sIII 3

May 25th, 2021 (edited)
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("bac.txt");
  5.  
  6. int main() {
  7.     int k;
  8.     fin >> k;
  9.     int lenMax = 0, nrSeq = 0, len = 0;
  10.     for (int x; fin >> x;) {
  11.         if (x % k == 0) {
  12.             len++;
  13.         } else {
  14.             if (len > lenMax) {
  15.                 lenMax = len;
  16.                 nrSeq = 1;
  17.             } else if (len == lenMax) {
  18.                 nrSeq++;
  19.             }
  20.             len = 0;
  21.         }
  22.     }
  23.     if (len > lenMax) {
  24.         lenMax = len;
  25.         nrSeq = 1;
  26.     } else if (len == lenMax) {
  27.         nrSeq++;
  28.     }
  29.     cout << lenMax << ' ' << nrSeq << endl;
  30.     return 0;
  31. }
  32.  
Add Comment
Please, Sign In to add comment