Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("bac.txt");
- int main() {
- int k;
- fin >> k;
- int lenMax = 0, nrSeq = 0, len = 0;
- for (int x; fin >> x;) {
- if (x % k == 0) {
- len++;
- } else {
- if (len > lenMax) {
- lenMax = len;
- nrSeq = 1;
- } else if (len == lenMax) {
- nrSeq++;
- }
- len = 0;
- }
- }
- if (len > lenMax) {
- lenMax = len;
- nrSeq = 1;
- } else if (len == lenMax) {
- nrSeq++;
- }
- cout << lenMax << ' ' << nrSeq << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment