题目链接: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

Problem Description
DouBiXp has a girlfriend named DouBiNan.One day they felt very boring and decided to play some games. The rule of this game is as following. There are k balls on the desk. Every ball has a value and the value of ith (i=1,2,...,k) ball is 1^i+2^i+...+(p-1)^i
(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”.
 
Input
Multiply Test Cases. 

In the first line there are two Integers k and p(1<k,p<2^31).
 
Output
For each line, output an integer, as described above.
 
Sample Input
2 3
20 3
 
Sample Output
YES
NO
 
Author
FZU
 
Source
 
Recommend
 

严格来讲,这应该是道数学题。但是假设是推导的话,数学沫沫表示死都推不出来。。。

于是果断。打几个小数据找规律了。

。。

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的更多相关文章

  1. 2014 Multi-University Training Contest 1/HDU4861_Couple doubi(数论/法)

    解题报告 两人轮流取球,大的人赢,,, 贴官方题解,,,反正我看不懂.,,先留着理解 关于费马小定理 关于原根 找规律找到的,,,sad,,, 非常easy找到循环节为p-1,每个循环节中有一个非零的 ...

  2. 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 ...

  3. 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) ...

  4. 2014 Multi-University Training Contest 9#11

    2014 Multi-University Training Contest 9#11 Killing MonstersTime Limit: 2000/1000 MS (Java/Others)   ...

  5. 2014 Multi-University Training Contest 9#6

    2014 Multi-University Training Contest 9#6 Fast Matrix CalculationTime Limit: 2000/1000 MS (Java/Oth ...

  6. 2014 Multi-University Training Contest 1/HDU4864_Task(贪心)

    解题报告 题意,有n个机器.m个任务. 每一个机器至多能完毕一个任务.对于每一个机器,有一个最大执行时间Ti和等级Li,对于每一个任务,也有一个执行时间Tj和等级Lj.仅仅有当Ti>=Tj且Li ...

  7. 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 ...

  8. 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 ...

  9. 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/ ...

随机推荐

  1. js-内置对象及相关语法

    1:如图(视频截取的) this指的是当前标签的对象. var ary=new Array("mark","jay","leslie"); ...

  2. 【PostgreSQL-9.6.3】函数(1)--数值型函数

    函数表示对输入参数返回一个特殊计算结果的值.PostgreSQL中的函数种类比较丰富,主要分为以下几类:数值型函数.字符型函数.日期和时间函数.条件判断函数.系统函数.加密函数以及其他函数.这篇文章只 ...

  3. DOM高级编程

    前言:W3C规定的三类DOM标准接口(换图)Core DOM(核心DOM),适用于各种结构化文档:XML DOM(Java OOP学过),专用于XML文档:HTML DOM,专用于HTML文档,下面了 ...

  4. JavaScript编程题(一)

    使用Javascript脚板输出如图所示的效果页面: 使用document.write()输出水平线 使用循环控制每个水平线的长度 答案:<!doctype html> <html ...

  5. 1、Scala安装与基础

    1.scala与java 2.安装 3.scala编译器 4.变量声明 5.数据类型 6.操作符 7.函数调用 8.apply函数 1.scala与java scala基于java虚拟机,所有scal ...

  6. Arduino DS18B20温度检测

    一.实物图 注:电阻选取4.7k欧 二.事例代码 注:先下载Onewire库到arduino libraries目录下,然后就有例子 #include <OneWire.h> // One ...

  7. (转)C#开发微信门户及应用(5)--用户分组信息管理

    http://www.cnblogs.com/wuhuacong/p/3695351.html 在上个月的对C#开发微信门户及应用做了介绍,写过了几篇的随笔进行分享,由于时间关系,间隔了一段时间没有继 ...

  8. layui 下拉框取值

    layui.use('form', function () { var form = layui.form; form.on('select(Status)', function (data) { c ...

  9. 数据迁移 Migration

  10. 构造函数+原型的js混合模式

    function Parent(){ this.name = "李小龙"; this.age = "30"; };Parent.prototype.lev=fu ...