Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define NMAX 100
- int n, k, v[NMAX];
- void Citeste()
- {
- cin >> n >> k;
- for (int i = 0; i < n; i++)
- cin >> v[i];
- }
- int Cub(int x)
- {
- int p, f = 2;
- while (x > 1)
- {
- p = 0;
- while (x % f == 0)
- {
- x /= f;
- p++;
- }
- if (p % 3)
- return 0;
- f++;
- }
- return 1;
- }
- int Poz(int a[], int n, int k)
- {
- if (n == k)
- return 0;
- int num = 0, maxNum = 0, p, solP;
- for (p = 0; p < k; p++)
- if (Cub(a[p]))
- num++;
- if (num > maxNum)
- {
- if (num == k)
- return 0;
- maxNum = num;
- solP = p - k;
- }
- while (p < n)
- {
- if (Cub(a[p - k]))
- num--;
- if (Cub(a[p]))
- num++;
- if (num > maxNum)
- {
- if (num == k)
- return p - k + 1;
- maxNum = num;
- solP = p - k + 1;
- }
- p++;
- }
- return solP;
- }
- void Scrie(int a[], int k, int p)
- {
- for (int i = p; i < p + k; i++)
- cout << a[i] << ' ';
- }
- int main()
- {
- Citeste();
- Scrie(v, k, Poz(v, n, k));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement