please explain what i m doing wrong and give me the correct code
Calculate the sum
#include<iostream>
#include<vector>
using namespace std;
int main() {
int n;
cin>>n;
vector<int> v;
for(int i=0;i<n;i++){
int no;
cin>>no;
v.push_back(no);
}
int q;
cin>>q;
while(q--){
int x;
cin>>x;
vector<int> temp = v;
for(int i=0;i<n;i++){
temp[i] = v[i] + v[(i-x+n)%n];
}
v = temp;
}
long long int sum = 0;
for(int i=0;i<n;i++){
sum = (sum + v[i])%1000000007;
}
cout<<sum<<endl;
}
sir this question is in 1-d array …i dont know vector now… pls explain what is wrong in my code first and then tell me how to rectify that mistake
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.