列表

详情


NC26003. Take Apples

描述

Bob and Alice have three piles of apples. There are M, N and N apples in each pile, respectively.

Clever Alice and idle Bob play the game. Alice and Bob take turns to take the apples from the game. The rules are as follows:

1. Choose a pile and take no more than S apples from it;
2. Or you can take the same number(can be larger than S) of apples from three piles at a time. If there is a pile with no apples, the rule cannot be used to take apples.

When the game starts, Alice takes the apple first. And they both take the optimal strategy.

The one who gets the last apple will win.

For given M,N,S, who will win, Alice or Bob?

输入描述

The input contains multiple sets of data

For each test case, each line contains three integersS,M,N, separated by spaces.

输出描述

For each test case, outputs a single line with the answer.

If Alice wins, output "Alice"; If Bob wins, output "Bob" (without quotes).

示例1

输入:

1 5 3
4 4 3

输出:

Alice
Alice

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++14(g++5.4) 解法, 执行用时: 4ms, 内存消耗: 340K, 提交时间: 2019-05-29 14:55:15

#include<bits/stdc++.h>
using namespace std;
int main(){
    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;
}

C++(clang++ 11.0.1) 解法, 执行用时: 2ms, 内存消耗: 284K, 提交时间: 2022-10-18 22:11:34

#include<bits/stdc++.h>
int s,n,m;
int main(){
	while (~scanf("%d%d%d",&m,&n,&s)) puts(m%(s+1)==0 && n<=s?"Bob":"Alice");
}

上一题