/* ROBOT CAN MOVE STEP 1,2 OR 3 AND PRINT YES OR NO , THAT THE
ROBOT CAN MOVE THE GIVEN DISTANCE */
# include <stdio.h>
main()
{
int i=0,j[3]={1,2,3};
long int n,x=0;
scanf("%ld",&n);
while(x<=n)
{
x+=j[i];
if(x==n)
{
printf("YES");
break;
}
if(i==2)
i=0;
else
i++;
}
if(x!=n)
printf("NO");
}
ROBOT CAN MOVE THE GIVEN DISTANCE */
# include <stdio.h>
main()
{
int i=0,j[3]={1,2,3};
long int n,x=0;
scanf("%ld",&n);
while(x<=n)
{
x+=j[i];
if(x==n)
{
printf("YES");
break;
}
if(i==2)
i=0;
else
i++;
}
if(x!=n)
printf("NO");
}
No comments:
Post a Comment