Created
October 25, 2016 13:36
-
-
Save bhi5hmaraj/5a64d52f02da1786d3fd0665916a4a21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
class Template { | |
private static void solve(FastScanner s1, PrintWriter out) { | |
/* | |
* This is a example on how to use this template | |
* use s1 object in the same way you use Scanner | |
* you can use out object the same way you would use System.out | |
* | |
* Below are the various uses | |
* | |
* Both the input and output streams gets automatically gets redirected to files when run in EdX servers | |
* | |
*/ | |
int N = s1.nextInt(); | |
int arr[] = s1.nextIntArray(N); | |
out.println("Hello , World"); | |
} | |
static String fileName = ""; // fill this with the name of the I/O files given for the specific problem | |
public static void main(String[] args) throws IOException { | |
InputStream inputStream = (System.getProperty("JUDGE") != null) ? (new FileInputStream(fileName + ".in")) : System.in; | |
OutputStream outputStream = (System.getProperty("JUDGE") != null) ? (new FileOutputStream(fileName + ".out")) : System.out; | |
FastScanner in = new FastScanner(inputStream); | |
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)), false); | |
solve(in, out); | |
in.close(); | |
out.close(); | |
} | |
static class FastScanner { | |
public BufferedReader reader; | |
public StringTokenizer st; | |
public FastScanner(InputStream stream) { | |
reader = new BufferedReader(new InputStreamReader(stream)); | |
st = null; | |
} | |
public String next() { | |
while (st == null || !st.hasMoreTokens()) { | |
try { | |
String line = reader.readLine(); | |
if (line == null) | |
return null; | |
st = new StringTokenizer(line); | |
} catch (Exception e) { | |
throw (new RuntimeException()); | |
} | |
} | |
return st.nextToken(); | |
} | |
public String nextLine() { | |
String str = null; | |
try { | |
str = reader.readLine(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return str; | |
} | |
public int nextInt() { | |
return Integer.parseInt(next()); | |
} | |
public long nextLong() { | |
return Long.parseLong(next()); | |
} | |
public double nextDouble() { | |
return Double.parseDouble(next()); | |
} | |
public char nextChar() { | |
return next().charAt(0); | |
} | |
int[] nextIntArray(int n) { | |
int[] arr = new int[n]; | |
for (int i = 0; i < n; i++) { | |
arr[i] = nextInt(); | |
} | |
return arr; | |
} | |
long[] nextLongArray(int n) { | |
long[] arr = new long[n]; | |
for (int i = 0; i < n; i++) { | |
arr[i] = nextLong(); | |
} | |
return arr; | |
} | |
int[] nextIntArrayOneBased(int n) { | |
int[] arr = new int[n + 1]; | |
for (int i = 1; i <= n; i++) { | |
arr[i] = nextInt(); | |
} | |
return arr; | |
} | |
long[] nextLongArrayOneBased(int n) { | |
long[] arr = new long[n + 1]; | |
for (int i = 1; i <= n; i++) { | |
arr[i] = nextLong(); | |
} | |
return arr; | |
} | |
public void close() { | |
try { | |
reader.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment