笔试压轴题会由于输入量较大的情况,输入输出所消耗的时间较多,导致超时,这时就需要快读快写。
import java.io.*;
import java.util.StringTokenizer;
// 注意类名必须为Main
class Main {
public static void main(String[] args) {
FastReader sc = new FastReader();
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
int a = sc.nextInt();
int b = sc.nextInt();
out.println(a + b);
// 最后记得flush,不然会没有输出
out.flush();
}
}
// 下面是快读模板。需要使用时直接贴在下面就好了
class FastReader{
StringTokenizer st;
BufferedReader br;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while (st==null||!st.hasMoreElements()){
try {
st=new StringTokenizer(br.readLine());
}catch (IOException e){
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}