Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大数据表示并不是必须的,附代码

Posted by astoninfer at 2015-06-07 19:59:53 on Problem 2348
解法,必胜状态的递归搜索
#include <cstdio>
#include <algorithm>

using namespace std;

bool getR(int a, int b){
	if(!a)	return false;
	if(b % a == 0)	return true;
	int c = b / a;
	bool ans = false;
	for(int i = c; i >= 1; i--){
		int newb = b - a * i;
		ans |= !getR(min(a, newb), max(a, newb));
		if(ans)	break;
	}
	return ans;
}

int main(){
	int a, b;
	while(~scanf("%d%d", &a, &b) && a){
		if(a > b)	swap(a, b);
		bool ans = getR(a, b);
		printf("%s wins\n", ans ? "Stan" : "Ollie");
	}
	return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator