#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; typedef long long LL; #define CLR(x,y) memset((x),(y),sizeof((x))) #define FOR(x,y,z) for(int (x)=(y);(x)<(z);++(x)) #define FORD(x,y,z) for(int (x)=(y);(x)>=(z);--(x)) #define FOR2(x,y,z) for((x)=(y);(x)<(z);++(x)) #define FORD2(x,y,z) for((x)=(y);(x)>=(z);--(x)) int n,k,m; int main(){ while(~scanf("%d%d%d",&n,&k,&m) && (n || m || k)){ //计算出胜者的编号,这里是0~n-1计算 int f = 0; for(int i = 1; i < n;++i){ f = (f + k)%i; } //根据结果开始位置,并把编号+1(变成1~n) printf("%d\n",(f + m) % n + 1); } return 0; } |
[2016-03-05][UVALive][3882][And Then There Was One]
原文:http://www.cnblogs.com/qhy285571052/p/5245926.html