oj刷题o(n)的复杂度过不了的时候就考虑到了scanner输入,才知道scanner效率太低,需要优化输入。
/** 快速输入类 */
class Reader {
static BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer tokenizer = new StringTokenizer("");
/** 获取下一段文本 */
static String next() throws IOException {
while ( ! tokenizer.hasMoreTokens() ) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt( next() );
}
static double nextDouble() throws IOException {
return Double.parseDouble( next() );
}
static double nextLong() throws IOException {
return Long.parseLong( next() );
}
/*关闭输入流*/
static void close() throws IOException {
reader.close();
}
}