Topic Links:
http://acm.hdu.edu.cn/showproblem.php?pid=5512
Test Instructions:
Given n points and a, B two initially labeled points, each time you can choose to have been labeled points in the two points I, J to mark the new point i+j or i-j, two people take turns mark, if who cannot mark, who loses, the output wins the person.
The following:
First we found that when a, B coprime, it through the above operation, it can be marked to 1th points, and then all points can be marked, when a, B is not coprime, write a few number of rules found GCD (A, A, a) multiple positions can be labeled.
Code:
#include <iostream>#include <algorithm>#include <stdio.h>using namespace STD;intN,t,a,b;intMain () {scanf("%d", &t); for(intt=1; t<=t;t++) {scanf("%d%d%d", &n,&a,&b);intG=__GCD (A, b);intnum=n/g-2;if(num%2==1)printf("Case #%d:yuwgna\n", t);Else printf("Case #%d:iaka\n", t); }}
"Hdu 5512" "2015ACM/ICPC Asia Shenyang Station" pagodas Test Instructions & Code (c + +)