First question a in more than 2014 schools | HDU 4861 couple doubi

Source: Internet
Author: User

Question Link

Q: I have k balls. I can give you a number of P and obtain K values (I = 1, 2 ,..., k): 1 ^ I + 2 ^ I +... + (p-1) ^ I (mod P ). then, the girlfriend obtains the data first, and then XP obtains the data, both of which hope to win. If the girlfriend wins, yes is output; otherwise, no is output.

Idea: This question is about to come out after calculation on paper. To win, it must be big at first, according to the rule, we can find that the final result of the remainder operation is either 0 or a certain number, so we can check whether there are odd or even numbers.

Official question:

1 # include <stdio. h> 2 # include <string. h> 3 # include <iostream> 4 5 using namespace STD; 6 7 int main () 8 {9 int K, P; 10 while (~ Scanf ("% d", & K, & P) 11 {12 if (K/P-1) % 2) puts ("yes "); 13 else puts ("no"); 14} 15 return 0; 16}
View code

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.