// C code for 1419. A Game with Numbers Problem code: NGM
#include<stdio.h>
int main()
{
int n;
while (scanf("%d",&n)==1)
(n%10)?(printf("1\n%d\n",n%10)):(printf("2\n"));
return 0;
}
#include<stdio.h>
int main()
{
int n;
while (scanf("%d",&n)==1)
(n%10)?(printf("1\n%d\n",n%10)):(printf("2\n"));
return 0;
}
Please explain the sample output, and how did you thought about the solution of NGM.
ReplyDeletelogic is very easy if u can give you opponent a num which is divisible by 10 he'll always loose because he can not change that num to another num which is divible by 10 as he can only subtract 0-9. so player1 always subtract the last digit of number(num%10). if player1 gets num which is divisble by 10 in starting itself then by same logic he'll loose the game !
ReplyDeletecould you give me an input where trofim win? (first line output 2)
ReplyDeleteExcellent publish, very informative. I just stumbled upon your blog and wished to say that I have really enjoyed browsing your blog posts.
ReplyDelete