2014 Multi-University Training Contest 1/HDU4861_Couple doubi (number theory/law)

Source: Internet
Author: User

2014 Multi-University Training Contest 1/HDU4861_Couple doubi (number theory/law)
The problem-solving report shows that the two take the ball in turn, and the big ones win, and post an official question, and, anyway, I don't understand, and, first, keep understanding about the ferma small theorem about the original root.
Find, sad, and the cycle section P-1. Each cycle contains a non-zero ball. Therefore, you only need to determine how many complete cycle sections are found, when determining the parity ,,,

#include 
 
  #include 
  
   #include 
   
    #include 
    
     using namespace std;int main(){    int k,p,i,j;    while(scanf("%d%d",&k,&p)!=EOF){        int q=k/(p-1);        if(q%2==0)            printf("NO\n");        else printf("YES\n");    }    return 0;}
    
   
  
 


Couple doubi Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 145 Accepted Submission (s): 122


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
OutputFor each line, output an integer, as described above.
Sample Input
2 320 3

Sample Output
YESNO

Source2014 Multi-University Training Contest 1

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.