Hangdian HDU 4861 couple doubi

Source: Internet
Author: User

Hangzhou-Hangzhou 2014 + school joint training first game 1001 couple doubi tease couples

I won't say much about this title.

Q: K balls are on the table. Each ball has a value. The value of the I-th ball is 1 ^ I + 2 ^ I +... + (p-1) ^ I (mod P ). P is a prime number. After that, P is better than a male. Finally, all balls have a higher total score. If you win, "yes" is output; otherwise, "no" is output ". (Both male and female adopt the most effective strategy ).

 

Of course, P is an important formula for odd prime numbers. This is the sum of formulas. Of course, it's easy to know. If you do not know, you can find the rule in the table.

Based on this important formula, we can easily write code.

# Include <iostream> # include <stdio. h> typedef long ll; int main (INT argc, const char * argv []) {ll K, P; while (~ Scanf ("% i64d % i64d", & K, & P) {If (K/P-1) % 2) puts ("yes "); else puts ("no");} return 0 ;}

 

------------------------------------------------------------------

Move forward

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.