how to approach problem of this kind?

I have came across this problem many time but never solved any. Can anyone tell me how to approach this kind of problems and under which tag I can find more problems of similar kind. Also provide links to some problems of this kind.

this program falls under the tag of simple if else conditions and iterations of loops.

  1. if n==1 BOB
  2. if n>1 search largest prime < n and so on…

links:

  1. https://www.codechef.com/MAY16/problems/LADDU/
  2. https://www.codechef.com/APRIL16/problems/COLOR/
  3. https://www.codechef.com/LOCFEB16/problems/CHOCOLAT/
    well i could remember only this many problems…

Check the comments under the editorial for this problem, you’ll find good explanation. You can find this type of problems under game-theory. This problem is basically based on observation. Hope this helps.

You can find such questions under Game theory tag here.
you can also try these 10 questions on hackerRank:

HackrRank