Click here to Skip to main content
15,885,881 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Players 1 and 2

are playing a game.

They have a pile containing N
coins. Players take alternate turns, removing some coins from the pile. On each turn, a player can remove either one coin or coins equal to some prime power (i.e., pm coins, where p is prime number and m

is a positive integer).

The game ends when the pile becomes empty. The player who can not make a move in his turn loses.

Which player wins?

What I have tried:

I donot know which algorith will be used to solve this problem?
Can you suggest me the exact solution ??
Posted
Updated 13-Jun-16 19:06pm
Comments
Peter_in_2780 14-Jun-16 0:07am    
This sounds like a variant of the game NIM. start here https://en.wikipedia.org/wiki/Nim and follow your nose.
PIEBALDconsult 14-Jun-16 0:17am    
We won't do your homework for you.
Krunal Rohit 14-Jun-16 1:03am    
So basically you haven't tried anything so far, right ?

KR
Member 9381668 14-Jun-16 1:06am    
I have no Idea about solution of problem. But after Peter' Comment I again start to solve this problem with NIM.

1 solution

As I assume, this a homework; it won't entertained here.
If you expect us to do your homework, that's not going to work. There's a pretty good reason behind this: "You won't be learn anything, if you expect others do your work for you".

You can try something on your own at first and when you stuck anywhere, anyone from here would do his/her best to help you out. But don't directly ask for the source code.

Read the Code Project Quick Answers FAQ[^] first :)

KR
 
Share this answer
 
Comments
Member 9381668 14-Jun-16 1:08am    
ok thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900