题意:从每轮的起始人的下一位开始查a[i]个人然后杀掉 k轮中每轮被杀的人的编号
题解:运用约瑟夫公式解决
J(n,k,i)代表每轮杀k人 第i轮被杀的人的编号 编号是0- n-1
int J(int n,int k,int i)
{
int g;
if(i==1)
return (k-1)%n;
else
{
g = (k + J(n-1, k, i-1)) % (n);
}
return g;
}
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
int a[105];
int J(int n,int k,int i)
{
int g;
if(i==1)
return (a[k])%n;
else
{
g = (a[k]+1 + J(n-1, k+1, i-1)) % (n);
}
return g;
}
int main(){
int n,k,i;
cin>>n>>k;
for(i=1;i<=k;i++)cin>>a[i];
for(i=1;i<=k;i++){
cout<<J(n,1,i)+1<<" ";
}
cout<<endl;
return 0;
}