Nyoj 837 _ The Game of Wyzhov

Wyzhov game

Wythoff Game

Time Limit: 1000  ms | Memory Limit: 65535  KB
Difficulty: 1
describe

Recently, ZKC students are learning games, and they have learned a great game problem--Wyzhov game.
I believe everyone has learned it? Haven't studied? no problem. I'm going to tell you about this great game problem.
There are two piles of stones, the number of which can be different. The game begins with two people taking turns taking stones.
The game stipulates that there are two different ways of taking each time:
one is that you can take as many stones as you want from any pile;
the other is that you can take the same number of stones from two piles at the same time.
In the end, the one who removes all the stones is the winner.
What we need to do today is to find the top n must-fail states.
What is a must-fail state? For example, we call (a, b) a state, and a and b are the number left in the two piles of stones, respectively. If a=0, b=0, we say this state is a must-lose state, because I can no longer play the game, even if it can be played, it is a must-lose state, you know, we are all very smart in the game. (0, 0) (1, 2) (3, 5)... are all must-fail states. What we need to do today is to find the first n must-fail states. Will not? All right!
Let me tell you again: Suppose that the nth must-fail state is (a, b) a is the smallest natural number that does not appear in the first n-1 must-fail states, b=a+n. Everyone should understand now. Well, our task is to make the top n losers. The 0th must-fail state is specified as (0,0).

enter
multiple sets of data.
The input is a number n (0<=n<=100000).
output
Find the top n must-fail states as required. See the example below for the output format.
sample input
3
1
Sample output
(0,0)(1,2)(3,5)(4,7)
(0,0)(1,2)
hint
Note: there is no space between each case
source
original
Uploaded by

ACM_Zhang Kaikai

//Play the table -- strange situation (the first player A will lose the situation)
#include<stdio.h>
#include<math.h>
int a[100001][2];

intmain()
{
	int n;
	double f1=(sqrt(5.0)+1)/2;
	for(int i=1;i<=10000;i++)
	a[i][0]=i*f1,a[i][1]=a[i][0]+i;
	while(~scanf("%d",&n))
	{
		printf("(0,0)");
		for(int i=1;i<=n;i++)
		{
			printf("(%d,%d)",a[i][0],a[i][1]);
		}
		puts("");
	}
	return 0;
}
// output directly according to the formula
#include<stdio.h>
#include<math.h>
intmain()
{
	int n;
	double f1=(sqrt(5.0)+1)/2;
	
	while(~scanf("%d",&n))
	{
		printf("(0,0)");
		for(int i=1;i<=n;i++)
		{
			printf("(%d,%d)",(int)(i*f1),int(i*f1+i));//Must be cast
		}
		puts("");
	}
	return 0;
}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325556077&siteId=291194637