Algorithm


Problem link- https://www.spoj.com/problems/TIPTOP/

TIPTOP - Tip Top Game

 

Alim and Sufian are two good friends. They love playing a game with numbers, and recently, they discovered a new game called “Tip Top”. The rule of the game is they took a number (N) randomly, after that they find all divisors of N. Then they starting to play the game first Alim took a divisor, then Sufian so on. The person who took the last divisor will win the game.

Every time the game started with Alim. Now Alim wants to know when he will win.

As you a good programmer your task is to find will Alim win or not.

Input

Input starts with an integer T (T ≤ 105), denoting the number of test cases. Each case starts with a line containing an integer N (1 ≤ N ≤ 1018) the number.

Output

For each case you have to print “Yes” if Alim will win otherwise “No” with case number. See the sample for exact formatting.

Sample

Input:
2
4
5

Output:
Case 1: Yes
Case 2: No

Problem setter: Ajharul Islam Barid, Dept. of CSE

Bangladesh University of Business and Technology (BUBT)

 

Code Examples

#1 Code Example with Python Programming

Code - Python Programming

import math

T = int(raw_input())
for i in range(T):
    N = int(raw_input())
    root = int(math.sqrt(N))
    if root * root == N:
        print('Case {}: Yes'.format(i + 1))
    else:
        print('Case {}: No'.format(i + 1))
Copy The Code & Try With Live Editor

Input

x
+
cmd
2
4
5

Output

x
+
cmd
Case 1: Yes
Case 2: No

#2 Code Example with C++ Programming

Code - C++ Programming

#include <bits/stdc++.h>
using namespace std;

int main()
{
int t ;
scanf("%d", &t);
int cs = 1;
while(t--)
{
long long int num;
scanf("%lld", &num);
long long int srt = sqrt(num) ;
if( srt*srt == num )
printf("Case %d: Yes\n", cs);
else
printf("Case %d: No\n", cs);
cs++;
}
}

Copy The Code & Try With Live Editor

Input

x
+
cmd
2
4
5

Output

x
+
cmd
Case 1: Yes
Case 2: No
Advertisements

Demonstration


SPOJ Solution-Tip Top Game-Solution in C, C++, Java, Python

Previous
SPOJ Solution - Test Life, the Universe, and Everything - Solution in C, C++, Java, Python