Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Strikeskids
Created February 21, 2018 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Strikeskids/125fdd8c9e1e818a7407ff8a983b1bff to your computer and use it in GitHub Desktop.
Save Strikeskids/125fdd8c9e1e818a7407ff8a983b1bff to your computer and use it in GitHub Desktop.
Template for writing ACM ICPC solutions in Java
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Icpc {
public static void main(String... args) throws Exception {
FastScan sc = new FastScan(new BufferedReader(new InputStreamReader(System.in)));
PrintWriter pw = new PrintWriter(System.out);
sc.close();
pw.close();
System.exit(0);
}
static class FastScan implements Closeable {
private BufferedReader br;
private StringTokenizer tk;
public FastScan(BufferedReader br) {
this.br = br;
}
public int in() throws NumberFormatException, IOException {
return Integer.parseInt(next());
}
public long ln() throws NumberFormatException, IOException {
return Long.parseLong(next());
}
public double db() throws NumberFormatException, IOException {
return Double.parseDouble(next());
}
@Override
public void close() throws IOException {
tk = null;
br.close();
}
public String next() throws IOException {
while (tk == null || !tk.hasMoreTokens()) {
String line = br.readLine();
if (line == null)
return null;
tk = new StringTokenizer(line);
}
return tk.nextToken();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment