【LA3882】And then there was one

做sb题也是一种乐趣,是吧……

#include<bits/stdc++.h>
#define N 10005
using namespace std;
int f[N],m,n,k;
int main(){
    while(scanf("%d%d%d",&n,&k,&m)&&n){
        int a=0;
        for(int i=2;i<=n;i++)a=(a+k)%i;
        a=(m-k+1+a)%n;if(a<=0)a+=n;
        printf("%d\n",a);
    }
}

 

posted @ 2017-06-13 11:28  zcysky  阅读(152)  评论(0编辑  收藏  举报