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");
}
- Comparable 与 Comparator 浅析
- 必应首页平铺背景图片的实现方案
- 我们是如何优化HAProxy以让其支持200万个并发SSL连接的?
- 【译】《Understanding ECMAScript6》- 第八章-Module
- 【译】《Understanding ECMAScript6》- 第七章-Promise
- 自定义gradview
- Redis 起步
- JVM参数详解及OOM
- 【译】《Understanding ECMAScript6》- 第五章-Class
- 【译】《Understanding ECMAScript6》- 第三章-Object
- 【译】《Understanding ECMAScript6》- 第二章-函数
- 【译】《Understanding ECMAScript6》- 第一章-基础知识(二)
- 【译】《Understanding ECMAScript6》- 第一章-基础知识(一)
- 聊聊C10K问题及解决方案
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法