hdu4861 Couple doubi---2014 Multi-University Training Contest 1
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4861
Couple doubi
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 238 Accepted Submission(s): 199
(mod p). Number p is a prime number that is chosen by DouBiXp and his girlfriend. And then they take balls in turn and DouBiNan first. After all the balls are token, they compare the sum of values with the other ,and the person who get larger sum will win
the game. You should print “YES” if DouBiNan will win the game. Otherwise you should print “NO”.
In the first line there are two Integers k and p(1<k,p<2^31).
2 3
20 3
YES
NO
pid=4871" style="color:rgb(26,92,200); text-decoration:none">4871
4869pid=4868" style="color:rgb(26,92,200); text-decoration:none">4868
pid=4867" style="color:rgb(26,92,200); text-decoration:none">4867
pid=4866" style="color:rgb(26,92,200); text-decoration:none">4866
严格来讲,这应该是道数学题。但是假设是推导的话,数学沫沫表示死都推不出来。。。
于是果断。打几个小数据找规律了。
。。
。
20 3
0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2 0 2
20 5
0 0 0 4 0 0 0 4 0 0 0 4 0 0 0 4 0 0 0 4
多试几个非常easy能够发现规律。。。仅仅有在p-1的倍数时有非0元素存在。
那么因为是博弈,大家每次肯定都是选那个比較大的数,所以。若是 k/(p-1)为奇数则先手必胜。否则平局
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<set>
#include<map>
#include<bitset>
using namespace std;
int main(){
int k,p;
while(cin>>k>>p){
if(k/(p-1)&1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
hdu4861 Couple doubi---2014 Multi-University Training Contest 1的更多相关文章
- 2014 Multi-University Training Contest 1/HDU4861_Couple doubi(数论/法)
解题报告 两人轮流取球,大的人赢,,, 贴官方题解,,,反正我看不懂.,,先留着理解 关于费马小定理 关于原根 找规律找到的,,,sad,,, 非常easy找到循环节为p-1,每个循环节中有一个非零的 ...
- HDU4888 Redraw Beautiful Drawings(2014 Multi-University Training Contest 3)
Redraw Beautiful Drawings Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2014 Multi-University Training Contest 9#11
2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others) ...
- 2014 Multi-University Training Contest 9#6
2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...
- 2014 Multi-University Training Contest 1/HDU4864_Task(贪心)
解题报告 题意,有n个机器.m个任务. 每一个机器至多能完毕一个任务.对于每一个机器,有一个最大执行时间Ti和等级Li,对于每一个任务,也有一个执行时间Tj和等级Lj.仅仅有当Ti>=Tj且Li ...
- hdu 4937 2014 Multi-University Training Contest 7 1003
Lucky Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) T ...
- hdu 4941 2014 Multi-University Training Contest 7 1007
Magical Forest Time Limit: 24000/12000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Other ...
- hdu 4939 2014 Multi-University Training Contest 7 1005
Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/ ...
随机推荐
- PCB Genesis增加轮廓字 实现原理
在Genesis增加汉字自带是不支持增加汉字的,如果需增加汉字需用到CAD 汉字库才可增加汉字,这里介绍一种脱离汉字库实现 Genesis增加轮廓字(如要变为实体,填空Surface可变为实体字) 一 ...
- indeed 5.13 第二次网测
题目描述,我找不见了,大概写一下想法和代码吧. 1. 没有看 2. 由于数据范围很小,就是简单的枚举,求全排列,然后更新答案. #include<bits/stdc++.h> #defin ...
- Combotree--别样的构建层级json字符串
1.先看效果 2.需要使用层级json格式,如: 3.先不要着急怎么去实现它,先来想想怎么用对象来描述它 4.代码 protected void Page_Load(object sender, Ev ...
- CSS样式优先级和权重问题(部分)
内联样式: <div style="font-size: 12px;">姓名</div> 外部样式: <link rel="styleshe ...
- 用 Django2.0 做 简单的BBS(前端用 Bootstrap)
实现目标: 开发首页显示BBS的标题和摘要,点击BBS的标题可跳转到BBS详细页面进行展示. 开发环境及开发工具: Python 3.6.3 Django 2.0 Pycharm 2017.3 实现过 ...
- C# 彻底关闭程序,包括循环
System.Environment.Exit(System.Environment.ExitCode); this.Dispose(); this.Close();
- MSP430之data type
- QS之force(3)
Example in project - First force signals in certain time and then noforce signals after some time. # ...
- Assembly之instruction之CMP
CMP[.W] Compare source and destinationCMP.B Compare source and destination Syntax CMP src,dst or ...
- Mac下php连接mysql数据库失败解决办法
通过phpmyadmin连接mysql成功,但是通过php连接数据库失败,执行如下php语句 ? 1 @mysql_connect("localhost","root&q ...