Article From:https://www.cnblogs.com/rmy020718/p/9061915.html

T29693 Take the stone

Title Description

Alice And Bob are playing games.

They have them.nn Stacksii A pile of stonesa_iai To guarantee the initial timea_i \leq a_{i + 1}(1 \leq i < n)aiai+1(1i<n) 。Now they take turns to operate these stones, and each operator can choose to satisfy them.a_i > a_{i – 1}ai>ai1 ( a_0a0 Be regarded as00 )A pile of stones and one from it. Who won’t be able to lose in the end. Alice first, they all use the best strategy to determine who will win in the end.

Input-output format

Input format:

 

First line an integern(1 \leq n \leq 100)n(1n100) ,The number of stone piles.

The next linenn Numberii Number isa_i(1 \leq a_i \leq 10^9)ai(1ai109) ,The meaning is as described above.

 

Output format:

 

“Alice” Or “Bob” to show who wins.

 

Input and output sample

Input sample #1: replication

1
1
Output sample #1: replication

Alice
Input sample #2: replication

1
2
Output sample #2: replication

Bob

One eye problem, a simple game theory.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
int n;
int a[110];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    ans+=a[1];
    for(int i=2;i<=n;i++)
    {
        if(a[i]>a[i-1])ans+=a[i];
    }
    if(ans%2==0)printf("Bob");
    else printf("Alice");
}

 

 

Similar Posts:

Link of this Article: Luogu 5 month, 5, #A

Leave a Reply

Your email address will not be published. Required fields are marked *