14多校第一场1001 (HDU4861)Couple Doubi

1001 (HDU4861) Couple Doubi

题目描述:

DouBiXp has a girlfriend named DouBiNan.One day they felt veryboring 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 numberthat is chosen by DouBiXp and his girlfriend. And then they take balls in turnand DouBiNan first. After all the balls are token, they compare the sum ofvalues with the other ,and the person who get larger sum will win the game. Youshould print “YES” if DouBiNan will win the game. Otherwise you should print“NO”.

 

大意:

Alice 和Bob 玩拿球游戏,座子上有 k 个球 Alice和Bob选定一个素数p,那么第i个球的价值是1^i+2^i+...+(p-1)^i (mod p) ,Alice 和 Bob每次从中取一个球,Alice先取,所有球取完后手中求价值大的那个人获胜(平局无赢家),问Alice是否能获胜。

 

解答:

首先,这道题是水题,打表很快就能找出来规律。

官方解法:


参考资料(from百度百科):

 

1.费马小定理

费马小定理是数论中的一个重要定理,其内容为:假如p是质数,且(a,p)=1,那么 a^(p-1) 1mod p)。即:假如a是整数,p是质数,且a,p互质,那么a(p-1)次方除以p的余数恒等于1

 

2.原根

m是正整数,a是整数,若am的阶等于φ(m),则称a为模m的一个原根。

 

3.

对于(a,n)=1的整数,满足a^r≡1 (mod n )的最小整数r,称为an的阶。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值