Sphere Online Judge

SPOJ Problem Set (classical)


Problem code: SHAKTI

Since very long time shaktiman and kilwish have been fighting with each other but the fight never came to end . So finally I came to rescue . I decided that the result of the fight will be decided by a mathematical game , in which I will write a number (N) . Kilwish and shaktiman will play the game alternatively and each of them would subtract a number(n) [n is less than N] such that N modulo n gives zero. The game is repeted turn by turn until the one , who now cannot make a further move looses the game

Shaktiman being weak at mathematics asks you for help , whether or not he can win in that particular case. If Shaktimaan wins that game then print "Thankyou Shaktiman" otherwise print "Sorry Shaktiman".The game begins with shaktimaan playing first move.It is well understood that both of them will make moves in optimal way.


Input contains test cases t (< 10^5) and followed by t numbers (1 <= N <= 10^6 ).


If Shaktimaan wins that game then print "Thankyou Shaktiman" otherwise print "Sorry Shaktiman".

Sample Input:

Sample Output:

Thankyou Shaktiman
Thankyou Shaktiman

Added by:αqfαяι∂ι™
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel Pentium G860 3GHz)

hide comments
2014-03-27 13:07:15 Santosh Kumar
Valar Morghulis!! :D
2014-03-23 19:56:15 Anubhav Balodhi ;-D
@Mitch thank U, yes this is an easy one...
2014-03-01 01:42:15 abhishek yadav
it intresting to solve it by understanding the proof... nt jst observation
2014-02-05 18:04:19 vank
somebody explain the test cases...
2014-01-27 23:47:42 Mitch Schwartz
I've observed that game theory is a weak point for many SPOJ users, based on number of solvers for other problems. If you found this easy, you could try e.g. DCEPC807, MYQ8, OVOXO, DCEPC12B. In my view this is ok for an easy classical problem, and might help increase interest in the field. (Also, if you've "solved" this problem without proving your solution is correct, you could learn something by proving it.)

Last edit: 2014-02-04 01:11:03
2014-01-27 06:55:15 Devesh Kumar
Can somebody correct me ? After subtracting n from N , now next player should look for the modulo of (N-n) which equals zero and recursively continue ?
2014-01-26 11:38:58 Kimi Räikkönen
this shouldn't even be in tutorial!
2014-01-25 15:43:46 ishaan
piece of cake :)
2014-01-25 12:00:40 shannider

Last edit: 2014-02-02 12:20:20
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.