im trying to make a solution for this problem without using the modulo concept CHRL4 Problem - CodeChef but my output is always coming wrong. please help someone.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, k, p, i, e, f, temp;
cin >> n >> k;
int a[100000];
for (i=0; i<n; i++)
cin >> a[i];
p=1;
for (i=0; i<=n; i++) {
while (1<=n-1 && n-1>=k) {
p *=a[i];
i++;
n--;
}
}
f=p*n*1;
cout << f;
return 0;
}