White cattle off season May 16 A stone's attendance problems (Game)

Links: https://ac.nowcoder.com/acm/contest/949/A
Source: Cattle-off network

Time limit: C / C ++ 1 second, 2 seconds languages other
space restrictions: C / C ++ 262144K, other languages 524288K
64bit the IO the Format: LLD%

Title Description

Small stone male and play games, a total of  n number of n, respectively  . 1 ~ n 1~n. They take turns fetching, stone upper hand. For each round access, you must select the remaining number in any of a number of the X- the X-, 
but also take away  the X- , the X-/ 2 , the X-/ 2 ⌋ / 2 ... If a number does not exist, stop access (not a number not take). Who caught the last number, whoever lost. Small
stone wanted to know if I can win. If the stone win, output  "Shi" , otherwise output  "Yang" (the quotation marks are not output).

Enter a description:

A total line, enter a number  n- n-.

Output Description:

A total line, the output "Shi" or "Yang" (without the quotes output).
Example 1

Entry

1

Export

That

Explanation

Stone removed only 1 1 Xiaoyang win.
Example 2

Entry

2

Export

Shi

Explanation

If the stone removed 1 1, a small sun can only take away 2 2 stone win.

Remarks:

1 the n- 1E9 

ideas: game theory problem, because the stone is the upper hand, it will definitely be a stone taken away and would be taken away in the first round, assuming n> 1, and stone to lose, then for all stone will lose of the first round stone
if you take a small positive becomes equivalent to the upper hand, it will lose a small positive, so in addition to n = 1 than losing a small positive, stone will win

the code:
 1 #include <iostream>
 2 #include <cstdio>
 3 
 4 using namespace std;
 5 int n;
 6 
 7 int main()
 8 {
 9     cin >> n;
10     if(n == 1)  cout << "Yang";
11     else cout << "Shi";
12     return 0;
13 }

 

 

Guess you like

Origin www.cnblogs.com/chuyds/p/11209453.html
Recommended