HDU 4861(多校)1001 Couple doubi
2024-08-30 11:03:22
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”.
(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 3
20 3
Sample Output
YES
NO
Source
Recommend
没听过什么费马定理,就仅仅知道这:
卧槽,就这样勉强写的,哎,说多了都是泪。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; long long k,p;
int main()
{
while(~scanf("%I64d%I64d",&k,&p))
{
int s=0;
if(p==2)
{
if(((k+1)/2%2))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
continue;
}
s=k/(p-1);
if(s%2)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
事实上仅仅要这样。。。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; long long k,p;
int main()
{
while(~scanf("%I64d%I64d",&k,&p))
{
int s=k/(p-1);
if(s%2)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
我小学没毕业,干只是那些高中生。。
最新文章
- .net自带的IOC容器MEF使用
- Android 蓝牙
- 16个基本颜色关键字 Basic color keywords
- thoughtworks编程题
- 【转】HTTP POST GET 本质区别详解
- 使用“原生”HTML DOM获取input的输入值并显示
- Oracle连接的若干错误
- 移动端动画使用transform提升性能
- MatlabR2014a 安装破解详细图文教程(附下载链接(内附CVX工具箱))
- Canvas_2
- diy toy: image auto-handler
- springBoot系列教程08:拦截器(Interceptor)的使用
- torch分类问题
- centos7下安装Go环境
- UOJ176 新年的繁荣
- Python基础6 面向对象
- MailBee.NET
- nagios系列(四)之nagios主动方式监控tcp常用的80/3306等端口监控web/syncd/mysql及url服务
- Spring事务管理详解_基本原理_事务管理方式
- Oracle初级第一天
热门文章
- python3 序列
- 4、linux开发中常用指令
- 修复STS4 server中没有Tomcat的问题(必看,官方推荐,包教包会,国内首发)
- [Angular] Creating an Observable Store with Rx
- #308 (div.2) B. Vanya and Books
- arm cpu的架构及分类说明
- C语言学习笔记:12_变量的存储方式和生存期
- Android中密码输入内容可见性切换
- Android 多个Fragment嵌套导致的三大BUG
- Android 自定义View——自定义点击事件