HDU4861 Couple doubi 【找规律】
来源:互联网 发布:淘宝卖家写给买家的话 编辑:程序博客网 时间:2024/05/16 08:53
Couple doubi
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 723 Accepted Submission(s): 522
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).
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 320 3
Sample Output
YESNO
在演草纸上分别列出p为3、5、7的情况,可以找到规律,即周期为p-1,每p-1个数里面只有一个数不等于0,于是可以求有多少个周期,周期数为奇数则先手赢。
#include <stdio.h>#include <math.h>int main(){ int k, p; while(scanf("%d%d", &k, &p) != EOF){ if(k / (p-1) % 2) printf("YES\n"); else printf("NO\n"); } return 0;}
0 0
- HDU4861 Couple doubi 【找规律】
- 找规律 hdu4861 Couple doubi
- HDU4861 Couple doubi
- HDU4861:Couple doubi
- hdu4861 找规律了
- hdu4861 Couple doubi---2014 Multi-University Training Contest 1
- hdu4861 Couple doubi 2014 Multi-University Training Contest 1
- 14多校第一场1001 (HDU4861)Couple Doubi
- 2014 Multi-University Training Contest 1 hdu4861 Couple doubi
- hdoj 4861 Couple doubi 【打表找规律】
- Hdu4861 - Couple doubi - 数论(2014 Multi-University Training Contest 1-1001)
- Couple doubi(费马小定理或打表找规律+简单博弈)
- HDU 4861-A - Couple doubi-数学规律/打表观察
- hdu 4861 Couple doubi
- hdu 4861 Couple doubi
- hdu-4861-Couple doubi
- hdu 4861 Couple doubi
- HDU 4861 Couple doubi
- Android开发笔记(2) Android Bundle类实现Activity之间通信
- Fox Observation
- JAVA Annotation
- UVA439
- ACM练习建议
- HDU4861 Couple doubi 【找规律】
- 顺序线性表的定义与基本操作
- STM32F103移植Raw-OS
- poj 2914 Minimum Cut 求无向图的最小割 Stoer-Wagner算法模板
- Linux内核的组成
- IsBackground对线程的重要作用
- C#tesseract使用
- <<书剑恩仇录>> 总结_2014.07.26
- HDU 1237