Skip to content

Instantly share code, notes, and snippets.

@cc2011
Created March 11, 2015 04:10
Show Gist options
  • Save cc2011/854f180d1fe930a98e11 to your computer and use it in GitHub Desktop.
Save cc2011/854f180d1fe930a98e11 to your computer and use it in GitHub Desktop.
TLE:http://www.codechef.com/problems/OJUMPS
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.*;
import java.util.Collections;
import java.io.*;
import java.math.BigInteger;
public class Main{
public static void main(String[] args) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
long n = Long.parseLong(br.readLine());
int[] jump = {1,2,3};
int cnt = 0;
int i=0;
for(; i <= n;) {
if( i == n) {
System.out.println("yes");
break;
}
cnt = cnt%3;
i += jump[cnt];
cnt +=1;
}
if(i >n)
System.out.println("no");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment