链接: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 15 4
输出例子:
Macle

-->

示例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 + ;
ll gcd( ll a, ll b ) {
if( a == ) {
return b;
}
if( b == ) {
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 > ; i -- ) {
if( m % i == ) {
flag = true;
break;
}
}
if( ( n & ) && flag ) {
cout << "Macle" << endl;
} else {
cout << "Tony" << endl;
}
}
return ;
}

最新文章

  1. linux下如何添加一个用户并且让用户获得root权限
  2. yum 源
  3. modelsim操作流程
  4. 24. javacript高级程序设计-最佳实践
  5. Linux重定向相关(转载帖,供自己cookbook)
  6. 写了一个自动打包并发布到tomcat的脚本
  7. SharePoint 2013 新功能探索 之 SPGroup、SPUser 事件处理程序 还要继续改进
  8. ios中xib的使用介绍
  9. Excel在任务栏中只显示一个窗口的解决办法
  10. mac xmind快捷键
  11. javascript 之执行环境-08
  12. c/c++ llinux epoll系列5 解除epoll_wait状态
  13. C#自定义事件模拟风吹草摇摆
  14. Feature Extractor[Inception v4]
  15. SpringBoot整合RabbitMQ,实现消息发送和消费以及多个消费者的情况
  16. benthos stream nats 集成试用
  17. Android笔记一.深入理解Intent和IntentFilters(一)
  18. Hibernate--关系映射和关联关系的CRUD
  19. java 查询solr时间格式
  20. 使用【单独】的一个&lt;script&gt;进行js文件的引用

热门文章

  1. pod指定node运行
  2. react解析: render的FiberRoot(三)
  3. 9.源码分析---SOFARPC是如何实现故障剔除的?
  4. Unity工程无代码化
  5. http客户端-性能比较系列-第一篇-单线程
  6. todaytt
  7. Spark 系列(十六)—— Spark Streaming 整合 Kafka
  8. AutoCAD二次开发(.Net)之创建图层Layer
  9. 查看centos中的用户和用户组和修改密码
  10. c排序