Home  >  Article  >  Java  >  Detailed explanation of examples of Java programming implementing fast IO in ICPC

Detailed explanation of examples of Java programming implementing fast IO in ICPC

黄舟
黄舟Original
2017-09-11 10:27:421377browse

This article mainly introduces the Java Fast IO in ICPC implementation source code, which has certain reference value. Friends who need it can learn about it.

This article will introduce Java’s implementation of ICPC fast IO. Let’s take a look at the specific code.

Do not handle EOF:


##

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream; 
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
 public static void main(String[] args) {
 InputStream inputStream = System.in;
 OutputStream outputStream = System.out;
 InputReader in = new InputReader(inputStream);
 PrintWriter out = new PrintWriter(outputStream);
 TaskD solver = new TaskD();
 solver.solve(1, in, out);
 out.close();
 } 
 static class TaskD {
 public void solve(int testNumber, InputReader in, PrintWriter out) { 
 }
 } 
 static class InputReader {
 public BufferedReader reader;
 public StringTokenizer tokenizer;
 public InputReader(InputStream stream) {
  reader = new BufferedReader(new InputStreamReader(stream), 32768);
  tokenizer = null;
 }
 public String next() {
  while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  try {
   tokenizer = new StringTokenizer(reader.readLine());
  } catch (IOException e) {
   throw new RuntimeException(e);
  }
  }
  return tokenizer.nextToken();
 } 
 public int nextInt() {
  return Integer.parseInt(next());
 } 
 }
}

Handle EOF:


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Random;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStream;
 
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
 public static void main(String[] args) {
 InputStream inputStream = System.in;
 OutputStream outputStream = System.out;
 InputReader in = new InputReader(inputStream);
 PrintWriter out = new PrintWriter(outputStream);
 TaskD solver = new TaskD();
 solver.solve(1, in, out);
 out.close();
 } 
 static class TaskD {
 public void solve(int testNumber, InputReader in, PrintWriter out) {
  while(in.hasNext())
  {
  int a=in.nextInt();
  int b=in.nextInt();
  System.out.println(a+b);
  }
 }
 }
 static class InputReader {
 public BufferedReader reader;
 public StringTokenizer tokenizer;
  public InputReader(InputStream stream) {
  reader = new BufferedReader(new InputStreamReader(stream), 32768);
  tokenizer = null;
 } 
 public boolean hasNext() {
  while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  try {
   String line = reader.readLine();
   if(line == null) return false;
   tokenizer = new StringTokenizer(line);
  } catch (IOException e) {
   throw new RuntimeException(e);
  }
  }
  return true;
 }
 public String next()
 {
  return tokenizer.nextToken();
 }
 public int nextInt() {
  return Integer.parseInt(next());
 }
 }
}

Summary

The above is the detailed content of Detailed explanation of examples of Java programming implementing fast IO in ICPC. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn