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.
 if n==1 BOB
 if n>1 search largest prime < n and so on…
links:
 https://www.codechef.com/MAY16/problems/LADDU/
 https://www.codechef.com/APRIL16/problems/COLOR/

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 gametheory. This problem is basically based on observation. Hope this helps.