What is wrong with the following code?


#1

#define mod 1000000007
#define ll long long
int findIndex(int k, int N){
for (int i = N-1; i>=0; i–){
k = k - (i+1);
if (k<=0) return i;
}
}
int devProd(int A){
ll ans;
ans = 1ll;
for (int i = 1; i<=A; i++){
if (A%i==0) ans = ((ans%mod)*(i%mod))%mod;
}
return ans;
}
vector Solution::solve(vector &A, vector &B) {
sort(A.begin(),A.end());
int N = A.size(), index, temp;
vector X;
for (int i = 0; i<B.size(); i++){
index = findIndex(B[i],N);
temp = devProd(A[index]);
X.push_back(temp);
}
return X;
}