Chef is at x=0.
1-jump: he will move from x -> x + 1
2-jump: he will move from x -> x + 2
3-jump: he will move from x -> x + 3
He will perform a lot of jumps in such a sequence: 1-jump, 2-jump, 3-jump, 1-jump, 2-jump, 3-jump, 1-jump, and so on.
Given an integer 0 ≤ a ≤ 10^{18}, find will he ever arrive at a.

QUICK EXPLANATION:

In one sequence of 1-jump, 2-jump and 3-jump, he moves from x -> x + 6. So, if intermediate jumps are removed for a minute, x will always be a multiple of 6. Now, if we consider intermediate jumps, we will also consider points of form 6*k - 3, 6*k - 5.

#include
using namespace std;
int main()
{
long a;
cout<<“enter value of a=”;
cin>>a;
if(((a%6)==0)||((a%6)==1)||((a%6)==3))
cout<<“yes”<<endl;
else
cout<<“no”<<endl;

@vivekshah1801 it took me 5 minutes to find the bug in your code. The bug is that the problem does not have any test cases!! You just have to take the number and show the output. I took care of this when I coded my solution but don’t know why it took so much time to find it in your code, lol.

Don’t know why I am getting a TLE… it’s working fine for me. I am using divisibility tests and char to int conversion. (I don’t want to use long long int.)