HDU 博弈

1517 A Multiplication Game
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6673 Accepted Submission(s): 3792

Problem Description
Stan and Ollie play the game of multiplication by multiplying an integer p by one of the numbers 2 to 9. Stan always starts with p = 1, does his multiplication, then Ollie multiplies the number, then Stan and so on. Before a game starts, they draw an integer 1 < n < 4294967295 and the winner is who first reaches p >= n.

Input
Each line of input contains one integer number n.

Output
For each line of input output one line either

Stan wins.

or

Ollie wins.

assuming that both of them play perfectly.

Sample Input
162
17
34012226

Sample Output
Stan wins.
Ollie wins.
Stan wins.

#include
int main()
{
    double N;
    while(scanf("%lf",&N)!=EOF)
    {
        while(N>18) N/=18;
        if(N>9) printf("Ollie wins.\n");
        else    printf("Stan wins.\n");
    }

    return 0;
}

2509和1907一样
Be the Winner
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4416 Accepted Submission(s): 2451

Problem Description
Let’s consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.
For example “@@@” can be turned into “@@” or “@” or “@ @”(two piles). two people get apples one after another and the one who takes the last is
the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).

Input
You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), followed by a line with n numbers, the number of apples in each pile. There is a blank line between cases.

Output
If a winning strategies can be found, print a single line with “Yes”, otherwise print “No”.

Sample Input
2
2 2
1
3

Sample Output
No
Yes

Source
ECJTU 2008 Autumn Contest

#include
#include
using namespace std;
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF&&N){
        int sum=0,flag=0;
        int a;
        for(int i=0;icin >> a;
            sum^=a;
            if(a>1)
                flag=1;
        }
        if(flag&&sum==0){
            printf("No\n");
        }
        else if(flag==0&&sum==1)
        {
            printf("No\n");
        }
        else
            printf("Yes\n");
    }
    return 0;
}

你可能感兴趣的:(hdu,博弈)