I translate my scanty knowledge from to . Share the main methods?

For example, in c ++, cin input is used for input, scanf is needed faster, cin + (Sync.tool .....) is needed even faster, and if it is very fast, then read the string and break it bit by bit.

In addition, than to replace the data input while(( c= getchar()) != EOF) . What are the analogues on java and what else can be useful? Here is an example task ( http://codeforces.com/problemset/problem/550/A?locale=ru )

  • it would be better to ask this question there. It seems that on CF they have already discussed all sorts of fast scanners. - pavel

1 answer 1

Here are the relevant recommendations, just in the annex to the Olympiad programming:

  • Scanner is the most convenient tool for reading input data in most tasks, but its speed leaves much to be desired. Use it only to read small inputs.

  • BufferedReader provides fairly quick input for most tasks. But on its own, this class only allows you to read individual characters and strings. To read tokens and numbers, use the StringTokenizer or StreamTokenizer .

  • PrintWriter is suitable for all cases and works fairly quickly. But his printf method is slow; calls to println(a + " " + b) also slow. Print one variable at a time (via print / println ), and then you will achieve maximum efficiency.