Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

showing wrong answer when it is working f9 on windows 7

$
0
0

Chef-jumping ques

http://www.codechef.com/MAY14/problems/OJUMPS

Following is my code, which is a success on ideone.com, the onl9 compiler:

public class Main

{

public static void main (java.lang.String[] args) throws java.io.IOException

{

if(args.length != 2)

{

java.lang.System.exit(0);

}

java.io.BufferedReader br=new java.io.BufferedReader(new

java.io.InputStreamReader(java.lang.System.in));

java.lang.String str=br.readLine();

if(str.length() > 19 || str.length() < 1)

{

java.lang.System.exit(0);

}

java.lang.String num="";

java.io.FileOutputStream foutinp=new java.io.FileOutputStream(args[0]);

byte b[]=str.getBytes();

foutinp.write(b);

foutinp.close();

java.io.File f=new java.io.File(args[0]);

if(f.exists())

{

java.io.FileInputStream fininp=new java.io.FileInputStream(args[0]);

int ch;

while((ch=fininp.read()) != -1)

{

num+=(char)ch;

}

int len=num.length();

for(int i=0;i<len;i++)

{

if(!(num.charAt(i) >= '0' && num.charAt(i) <= '9'))

{

java.lang.System.exit(0);

}

}

if(len!=1)

{

num=num.charAt(len-2)+""+num.charAt(len-1);

}

else

{

num=""+num.charAt(len-1);

}

int no=java.lang.Integer.parseInt(num);

java.lang.String msg;

if(no==0)

{

msg="yes";

}

else

{

no=no%6;

if(no==0)

{

msg="yes";

}

else

{

no=no-1;

if(no==0)

{

msg="yes";

}

else

{

no=no-2;

if(no==0)

{

msg="yes";

}

else

{

msg="no";

}

}

}

}

java.io.FileOutputStream foutop=new java.io.FileOutputStream(args[1]);

byte bt[]=msg.getBytes();

foutop.write(bt);

foutop.close();

java.io.File f2=new java.io.File(args[1]);

if(f2.exists())

{

java.io.FileInputStream fin=new java.io.FileInputStream(f2);

msg="";

while((ch=fin.read()) != -1)

{

msg+=(char)ch;

}

java.lang.System.out.println(msg);

}

else

{

java.lang.System.exit(0);

}

}

else

{

java.lang.System.exit(0);

}

}

}


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>