• 牛客网 湖南大学2018年第十四届程序设计竞赛重现赛 A game


    链接:https://www.nowcoder.com/acm/contest/125/A
    来源:牛客网

    Tony and Macle are good friends. One day they joined a birthday party together. Fortunately, they got the opportunity to have dinner with the princess, but only one person had the chance. So they decided to play a game to decide who could have dinner with the princess.

    The rules of the game are very simple. At first, there are n sticks. Each of exactly m meters in length. Each person takes turns. For one move the player chooses just one stick and cut it into several equal length sticks, and the length of each stick is an integer and no less than k. Each resulting part is also a stick which can be chosen in the future. The player who can't make a move loses the game ,thus the other one win.
    Macle make the first move.

    输入描述:

    the first line contains tree integer n,m,k(1 <=  n,m,k  <=  10

    9

    )

    输出描述:

    print 'Macle' if Macle wins or 'Tony' if Tony wins,you should print everything without quotes.

    示例1

    输入

    复制
    1 15 4

    输出

    复制
    Macle
    示例2

    输入

    复制
    4 9 5

    输出

    复制
    Tony


    有n根m长的绳子,每次你可以把任意一根绳子分成不小于k长度的任意根绳子。分到的绳子在下次可以被分解。Macle先开始,谁先不能对这些绳子进行操作就输了。
    如果n是偶数的话,那么Macle肯定输了。Macle要赢的条件是:(1)n是奇数的(2)m有小于k的因子,这样我就可以一次性把m分解成一个Tony无法再分解的数

    #include<algorithm>
    #include<iostream>
    #include<cstring>
    #include<cstdlib>
    #include<cstdio>
    #include<string>
    #include<cmath>
    #define debug(a) cout << #a << " " << a << endl
    using namespace std;
    typedef long long ll;
    const ll inf = 1e9;
    const ll maxn = 1e3 + 10;
    ll gcd( ll a, ll b ) {
        if( a == 0 ) {
            return b;
        }
        if( b == 0 ) {
            return a;
        }
        return gcd( b, a%b );
    }
    int main() {
        std::ios::sync_with_stdio(false);
        ll n, m, k;
        while( cin >> n >> m >> k ) {
            ll num = m / k;
            bool flag = false;
            for( ll i = num; i > 1; i -- ) {
                if( m % i == 0 ) {
                    flag = true;
                    break;
                }
            }
            if( ( n & 1 ) && flag ) {
                cout << "Macle" << endl;
            } else {
                cout << "Tony" << endl;
            }
        }
        return 0;
    }
    彼时当年少,莫负好时光。
  • 相关阅读:
    phpwind管理权限泄露漏洞
    CGI Hack与Webshell研究资料整理
    深入浅出net泛型编程[转载]
    加上checkbox的treeview控件源程序
    BCB消息消息机制
    开源ZPU介绍
    带复选框可以多选的组合框控件 TCheckCombobox,非常完美
    别人用delphi写的很简单实用的多列功能的treeview treelistview
    智能DVR视频监控系统,源代码
    delphi事件参数sender的用法例程
  • 原文地址:https://www.cnblogs.com/l609929321/p/9097328.html
Copyright © 2020-2023  润新知