-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOExperiment.java
More file actions
89 lines (76 loc) · 1.97 KB
/
IOExperiment.java
File metadata and controls
89 lines (76 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package problems.codechef;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class IOExperiment {
static long readInput(){
long ret = 0;
try{
BufferedInputStream b=new BufferedInputStream(System.in);
char c = (char) b.read();
while(c<'0' || c>'9') c = (char) b.read();
while(c>='0' && c<='9') {
ret = 10 * ret + c - 48;
c = (char) b.read();
}
b.close();
}catch (IOException e) {
e.printStackTrace();
}
return ret;
}
public static String readInputDemo(){
BufferedInputStream b=new BufferedInputStream(System.in);
StringBuilder s=new StringBuilder();
long val=0;
try {
int c=b.read();
while(c!='\n'){
s.append((char)c);
c=b.read();
}
} catch (Exception e) {
// TODO: handle exception
}
return s.toString();
}
public static void main(String[] args) {
long temp1=System.nanoTime(),temp2;
int a,b;
String s[]=readInputDemo().split("\\s");
a=Integer.parseInt(s[0]);
b=Integer.parseInt(s[1]);
System.out.println(a+" "+b);
temp2=System.nanoTime();
System.out.println(temp2-temp1);
temp1=System.nanoTime();
Scanner sc=new Scanner(System.in);
a=sc.nextInt();
b=sc.nextInt();
System.out.println(a+" "+b);
temp2=System.nanoTime();
System.out.println(temp2-temp1);
temp1=System.nanoTime();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try {
String p[]=br.readLine().split("\\s");
a=Integer.parseInt(p[0]);
b=Integer.parseInt(p[1]);
System.out.println(a+" "+b);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
temp2=System.nanoTime();
System.out.println(temp2-temp1);
/*BufferedInputStream b=new BufferedInputStream(System.in);
try {
System.out.println((char)b.read());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
}
}