|
|
вернуться в форумHow to get speed 0.001 seconds ???? Re: How to get speed 0.001 seconds ???? Послано c_pp 13 дек 2016 20:59 -- use fread | fwrite; -- do not use << if >> statement or minimize it; -- minimize div and mod operations ( % , / operators); -- instead of % , / operators may to use pre-calculated arrays. -- and last, need lucky :) Re: How to get speed 0.001 seconds ???? Your program ate 12 Mb memory. So I suppose you are reading the whole numbers and then do addition. It isn't necessary. It's possible to add numbers digit by digit (yes, from high digits to low) without any arrays usage - 0.3s even using scanf/printf. And yes, use fread/fwrite. Edited by author 13.12.2016 22:15 Re: How to get speed 0.001 seconds ???? Послано c_pp 16 дек 2016 21:25 10^6 numbers --> input file size ~4 Mbytes, and output file size ~1 Mbytes. MY PC i-core 3 , 3 GB RAM, gcc 5.4.0 with option: g++ -Wall -O3 -std=c++14 reads/writes took 6-9 milliseconds. So there need something magic tricky to solve this with time < 1 milliseconds !!!!! Re: How to get speed 0.001 seconds ???? I got 0.001s AC!! buffered i/o helped me. |
|
|