Advertisement
hopingsteam

Untitled

May 6th, 2020
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include    <iostream>
  2. #include    <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("fisier.in");
  7.  
  8. int main()
  9. {
  10.     unsigned int k;
  11.     fin >> k;
  12.  
  13.     int lungMax = 0, lungContor = 1, lungCurenta = 0;
  14.     unsigned int nr;
  15.     while(fin >> nr)
  16.     {
  17.         if(nr % k == 0)
  18.         {
  19.             lungCurenta++;
  20.         }
  21.         else
  22.         {
  23.             if(lungCurenta != 0)
  24.             {
  25.                 if(lungCurenta > lungMax)
  26.                 {
  27.                     lungMax = lungCurenta;
  28.                     lungContor = 1;
  29.                 }
  30.                 if(lungCurenta == lungMax)
  31.                     lungContor++;
  32.             }
  33.             lungCurenta = 0;
  34.         }
  35.     }
  36.     cout << lungMax << " " << lungContor;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement