JAVA in online programming [Uva]

Sometimes we try to use Java in online programming like Uva.Though it is bad in Uva,some programmers think that it is helpful to use Java in contests.

We know that Java support in the judge is bad. But if you want to try it, take this considerations into account.

The Java programs submitted must be in a single source code (not .class) file. Really, they are compiled and run as native applications using the gcj compiler. They must read and write the standard input/output, as the other languajes. Note that java::io use is restricted; this implies that some features (for example, to create a DataInputStream variable with System.in as argument, in order to use readLine to read strings from the standard input) are not available. Also, network and other functions are not allowed. Threads are also not ready. However, methods from math, util and some other common packages are authorized. If you find any useful function for a scientific program not available, please contact Uva about it.

I am posting here my code of Uva 10055 so that you can get an idea about submitting solutions using java…


// import ::io is restricted

import java.util.*;

class Main //class name must be Main and non-public
{
public static void main(String[] a){
long hn,mn;

Scanner s=new Scanner(System.in);

while(s.hasNext()){
hn=s.nextLong();
mn=s.nextLong();

if( hn<mn )
System.out.println(""+(mn-hn));
else
System.out.println(""+(hn-mn));
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *