And Then There Was One
Sample Input
Sample Output
//设f[i]为(原约瑟夫问题)第i次要删除的标号
#include<cstdio>
using namespace std;
const int N=1e4+;
int n,m,k,f[N];
int main(){
while(scanf("%d%d%d",&n,&k,&m)==&&n){
//f[1]=0;
//for(int i=2;i<=n;i++) f[i]=(f[i-1]+k)%i;
//int ans=(m-k+f[n]+1)%n;
int s=;
for(int i=;i<=n;i++) s=(s+k)%i;
int ans=(m-k+s+)%n;//这3句话来源于上面
if(ans<=) ans+=n;
printf("%d\n",ans);
}
return ;
}