##
__Tip Top Game __

Link to the question: TIPTOP###
__HINT :__

The question asks tells us to find the divisors of a given number and find the winner. Winner is the person who takes the last divisor. So it can very well understood that since Alim plays first, in order to him to win there must be odd number of divisors of the given number else he loses.

By doing some paper work you will see that all the numbers which are a perfect square have odd number of divisors else they even number of divisors.

###
__SOURCE CODE__:

#include<iostream>

#include<stdio.h>

#include<math.h>

using namespace std;

int main()

{

int t ;

scanf("%d", &t);

int c = 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", c);

else

printf("Case %d: No\n", c);

#include<stdio.h>

#include<math.h>

using namespace std;

int main()

{

int t ;

scanf("%d", &t);

int c = 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", c);

else

printf("Case %d: No\n", c);

c++;

}

}

}

}

Are you sure about this ?

ReplyDelete