Number theory papers - Weizuo Fu Game (Wythoff Game)

· Konjac do not understand - trained, trained, trained, sorry

· To mix Lianshu model

 

· The stuff :( Source: Luo Gu problem solution + network)

A Game Bash (Bash Game):

A and B a number of packets, each packet least one person, reported that up to 4, 30 to see who report. This should be the oldest game on Game Bash the bar.

In fact, if you know the principle, this game is a little luck at all, and only about FLAC upper hand, such as the number reported for the first time, A reported number k, then the number of 5-k B report, then the problem becomes after a few newspaper B is, a and B, the number one newspaper to see who should report to the 25, and then becomes 20,15,10,5, when that time 5, no matter how a report number, the last number is certainly a B report, you can see out as in B said subsequent games are not lose.

So if we want to packet number n, each reported a minimum, a maximum packet number m, so we can find an integer k and r, so that n = k * (m + 1) + r, into the above example, we can know, if r = 0, then losing the upper hand; otherwise, the upper hand to win.

Second Weizuo Fu Game (Wythoff Game):

There are a number of piles of each article, the two turns taken from a stack wherein the at least one article, not up, or from the same piles of items simultaneously, by taking a predetermined final finish victory.

He said direct conclusions, if the initial value of piles of articles (x, y), and x <y, then the other z = yx;

Note w = (int) [((sqrt (5) +1) / 2) * z];

If w = x, the upper hand is doomed to failure, or the upper hand win.

Three Nimes Game (Nimm Game):

Nimes Game refers to such a game of chance: there any heap objects, the number of items per stack is arbitrary, the two sides take turns to reap items, each can only take part or all of the items from a pile of articles, at least take a pieces, the last item to get people to win.

The conclusion is: the number of items per stack up all exclusive or, if the resulting value is 0, then losing the upper hand, otherwise the upper hand to win.

Four Fibonacci Qi Bo Yi:

There are a bunch of articles, the two take turns retrieving items, taking the upper hand at least one and up to no upper limit, but can not get finished goods, the number of items after each taking several items can not exceed twice the last time and take at least one, Remove the last item of man wins.

The conclusion is: to win the upper hand if and only if n is not a Fibonacci (n is the total number of items)

Betty five Theorem (Betti theorem).:

Set a, b is a positive irrational number, and 1 / a + 1 / b = 1. Referred to P = {[na] | n is any positive integer}, Q = {[nb] | n is any positive integer}, ([x] 'refers to take x integer part) of the P and Q are Z + is a division, i.e. P∩Q P∪Q empty set and the set of positive integers N +.

The conclusion is: N + = P∪Q.

-------------------------------- gorgeous dividing line --------------- -------------------------

example:

Los valley entrance: P2252 take stones game

topic:

There are two piles of gravel, any number can be different. Start of the game by two people take turns to stone. The provisions of the game, each time there are two different emulated, one can take away as many stones in any pile in; the second is simultaneously removed in the same number of stones in two piles. Finally, all the stones were taken to finish the winner. Now given the initial number of piles of stones, you first take, assuming that both sides have taken the best strategy, and finally ask you is the winner or loser.

Gangster problem solution ideas:

1. See above knowledge.

2. Luo Gu problem solution 2.

Code:

#include<iostream>
#include<cmath>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	int f;
	if(a<b) swap(a,b);
	int x=(a-b)*(sqrt(5.0)+1.0)/2.0;
	if(x==b) f=0;
	else f=1;
	cout<<f<<endl;
	return 0;
}

Guess you like

Origin www.cnblogs.com/konglingyi/p/11285444.html