2014---多校训练一(A Couple doubi)

Couple doubi

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1087    Accepted Submission(s): 762

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

2014 Multi-University Training Contest 1

数论: 费马引理

官方解题报告:

代码:

#include<stdio.h>
 void main(){
 int k,p;
 while(~scanf("%d%d",&k,&p))
   k/=(p-1),puts(k&1)?"YES":"NO");
}
时间: 2024-11-05 21:41:24

2014---多校训练一(A Couple doubi)的相关文章

2014多校训练九(HDU 4960 HDU 4961 HDU 4965 HDU 4968 HDU 4969 HDU 4970)

HDU 4960 Another OCD Patient 题意:给你一串数字  相邻x个数字合并成一个数字(相加)有一定代价  问  最少花费多少使得串变成回文串 思路: 读完题感觉像dp  数据范围也像  就开始想怎么表示状态  最简单的应该想到dp[i][j]表示i到j区间变成回文串的最小花费  状态想好了想做法  考虑将串分成AAAABBBBBBBCCC三段  即所有A合成一个数字  C也是  而且A和C相等  那么B串就变成了子问题  但是A和C是不是都要枚举呢?  这个串所有元素都是正

hdu 4970 Killing Monsters(简单题) 2014多校训练第9场

Killing Monsters                                                                        Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Kingdom Rush is a popular TD game, in which you should b

hdu 4923 Room and Moor(数学题)2014多校训练第6场

Room and Moor                                                                          Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem Description PM Room defines a sequence A = {A1, A2,..., AN}, each of

hdu 4902 Nice boat(2014多校训练第4场 1006)

Nice boat                                                                           Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description There is an old country and the king fell in love with a d

hdu 4960 Another OCD Patient(dp)2014多校训练第9场

Another OCD Patient                                                                         Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description Xiaoji is an OCD (obsessive-compulsive disorder) pat

hdu 4965 Fast Matrix Calculation(矩阵快速幂)2014多校训练第9场

Fast Matrix Calculation                                                                   Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description One day, Alice and Bob felt bored again, Bob knows Ali

hdu 4901 The Romantic Hero(计数dp)2014多校训练第4场1005

The Romantic Hero                                                                               Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description There is an old country and the king fell in lov

hdu 4915 Parenthese sequence(模拟)2014多校训练第5场

Parenthese sequence                                                                     Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description bobo found an ancient string. The string contains only t

hdu 4939 Stupid Tower Defense(DP)2014多校训练第7场

Stupid Tower Defense                                                                         Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description FSF is addicted to a stupid tower defense game. Th

hdu 4937 Lucky Number(数学题 进制转换)2014多校训练第7场

Lucky Number                                                                          Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description "Ladies and Gentlemen, It's show time! " "A thie