F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Stone Game

Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1    Accepted Submission(s): 1


Problem Description
  Cdfpysw and Nanaya love to play some games together. Today, they find a new stone game.
  There are N piles of stones on the table, there are a_i stones in the i_th pile.
  They will play in turns. In each turn, one player should take out some stones in one pile. If stones he takes is k, all stones before he takes in that pile is p. It should be satisfied that k > 0 and gcd(k, p) = 1. gcd(a, b) means the greatest common divisor of a and b.
  Cdfpysw will take the first turn, and the first one who cannot take stones is the loser.
  If they will both use the best strategy for win, can you predict who will be the winner?
 

Input
  The first line is an integer T, means the number of cases.
  For each case:
    The first line is an integer N, means the number of piles.
    The next line contains N integers a_1, a_2, ..., a_N, means the number of stones in each pile.
  T <= 50
  N <= 106
  0 <= a_i <= 106
 

Output
  In each case, you should output "Case #%d: " first.
  Then you should print the winner's name, "Cdfpysw" or "Nanaya".
 

Sample Input
3 2 2 4 2 1 3 3 1 3 5
 

Sample Output
Case #1: Nanaya Case #2: Cdfpysw Case #3: Nanaya
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 19:13:01, Gzip enabled