View Code of Problem 80

#include <cstdio>
#include <iostream>
using namespace std;
int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0)
			break;
		int res=1;//只有两个人的时候胜利者一定在1号位置,0号是起始位置 
		for(int i=3;i<=n;i++){//从只有三个人开始推 
			res=(res+3)%i; //胜利者的位置往后移动3 在环里的什么位置呢?? 
		}
		cout<<res+1<<endl; 
	}
}

Double click to view unformatted code.


Back to problem 80