F-Take Apples(2019HBCPC)

Original title connection: https://ac.nowcoder.com/acm/contest/903/F

Title effect: There are three groups of apples, respectively, M, N, N apples, there are two kinds of operation.

1 take no more than a stack S of apples from any

2. respectively depicting the same arbitrary apple from the three-pile, but can not exceed the number of owned

People can not take zero or take an apple, an apple win the final victory. Alice upper hand, Bob FLAC.

 

Thinking: Game Theory
1. When n == m, Alice can once removed, Alice wins

2. When n> m, the piles are left to be taken (nm) th, then Alice win;

3. When n <m <time = s, and three groups of apples, can take any number of cases consistent with the results from the pile, and m ^ n ^ n is not necessarily 0, Alice win;

4. When consistent n <s + 1 <m, the number and only one pair of apple m each taking a case where the result does not exceed S, i.e. when m% (s + 1)! When = 0, Alice win, m% (s + 1) == 0 time, Bob win;

5. When s + 1 <= n <m, the step must be taken from the stack the number of three required to obtain n <s + 1, m% (s + 1) == 0, so Alice win .

In summary, only n <s + 1, m% (s + 1) == 0 win by Bob, Alice win other.

 

ac Code:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ldb long double
#define db double
#define lowbit(x) (x&-x)
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define endl "\n"
#define rush() int T;scanf("%d",&T);while(T--)
#define mem(a,b) memset((a),(b),sizeof(a))
const db pi = acos((db)-1);
const ll MAXN = 5e8;
const ll mod = 1e9+7;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdin);
    
    int s,m,n;
    
    while(~scanf("%d%d%d",&m,&n,&s))
    {
        if(m%(s+1)==0&&n<(s+1))puts("Bob");
        else puts("Alice");
    }
    
    return 0;
} 

 

Guess you like

Origin www.cnblogs.com/Ogreee/p/10964492.html