地址: https://cdn.luogu.com.cn/upload/image_hosting/a46kgm2x.png
代码:
#include <bits/stdc++.h>
using namespace std;
int a[10000],cnt=0;
int main()
{
int n,i,t;
cin >> n;
for(i=1;i<=n;i++)
{
cin >> a[i];
}
cin >> t;
i=0;
while(1)
{
if(i==n)
{
i=0;
}
i++;
if(t-a[i]>0)
{
t=t-a[i];
cnt++;
}
else if(t-a[i]==0)
{
cout << cnt % n +1<< endl;
return 0;
}
else
{
cnt++;
cout << cnt % n << endl;
return 0;
}
}
return 0;
}