HDU 4861 couple doubi

Source: Internet
Author: User

Couple doubi Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 607 accepted submission (s): 435


Problem descriptiondoubixp 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 bils 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 bils in turn and doubinan first. after all the bils are token, they compare the sum of values with the other, and the person who get larger sum will win the game. you shoshould print "yes" if doubinan will win the game. otherwise you shoshould print "no ".
Inputmultiply test cases.
In the first line there are two integers K and P (1 <K, P <2 ^ 31 ).
 
Outputfor each line, output an integer, as described above.
Sample Input
2 320 3
 
Sample output
YESNO
 
Authorfzu
Source2014 multi-university training contest 1

Question: The level is a little scum. During the game, you can view the regular expression.


#include <iostream>#include <cstdio>using namespace std;int main(){    int k,p;    while(cin>>k>>p)    {        if(p)        if(k/(p-1)%2==0) cout<<"NO"<<endl;        else cout<<"YES"<<endl;    }    return 0;}




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.