📜 ⬆️ ⬇️

New Year's Programming Contest 2013 (C ++)

We all heard the saying: how to celebrate the new year - so you can spend it. Olivier aside!

It would be inhumane to count on 5 hours of hellish programming on a holiday, because there is only one task and it is very lapidary:
The program must read from the standard input stream an integer N (from 1 to 2 30 ), and print the sum of prime numbers less than or equal to N.
The winner is the one who writes the fastest solution that passes all the tests (at least one wrong answer - and the decision is rejected). The speed of the solution is estimated on tests in the region of the upper limit of the permissible range N (but not exactly 2 30 ).

The winner receives universal recognition, hundreds of karma and a pleasant feeling that he tore all at Habré. For many years, the younger generation of developers will admire its code, and the girls will throw their caps into the air. At least the first 4 read-only users will be invited to Habr.
')
Limitations:
  1. The file size with the solution - no more than 1024 bytes, excluding the first line with a comment
    (brevity is the soul of wit)
  2. Only one programming language - C ++ performed by clang 3.2, only standard libraries (+ pthreads). If you use C ++ 11, specify your version of libc ++ just in case. With OpenMP / TBB - no luck, with clang they still get along badly.
    There is no need to write a lot of code here, so even if C ++ is not your main language, it will be easy to understand it at a level sufficient to solve the problem.
  3. Tests will be conducted on 64-bit Linux.
    You can use 4 processor cores (i7-3820) and no more than 30 GB of memory.
  4. The valid time for each test is no more than 60 seconds .

Decision making, deadlines and where to send
Decisions are made until 23:59 (Moscow time) on January 1, 2013 at contest@14.by, the decision file must be attached to the letter - no need to insert the code into the letter itself!

The first line of the decision should contain a comment like:
//@BarsMonster 
Where BarsMonster is the name of your user on HabraHabr (users can participate and read-only, register )

Results and decisions will be published on Habré - if possible not later than the 2nd of January.

Example solution: (a little time out, 242 bytes)
 //@BarsMonster #include<iostream> using namespace std; int main() { __int64_t n, sum=0; cin>>n; for(__int64_t i=2;i<=n;i++) { for(__int64_t j=2;j<i;j++) if(i%j==0)goto next; sum+=i; next:; } cout << sum << endl; } 

Work example:
 test@lbox2:~$ ./a.out 10 17 test@lbox2:~$ time ./a.out 100000 454396537 real 0m7.073s user 0m4.693s sys 0m0.000s 


Update: 22 minutes after the start of the competition - and the first decision has already arrived :-)
Update: 3 hours after the start of the competition - 10 solutions.
Update: To reduce the amount of drama removed the ban on re-sending, but please do not abuse.
Update: For those who write in VisualStudio - the simplest test for compilability can be done here: llvm.org/demo (do not forget to choose C ++)
Update: 3 hours before the end of the competition - the number of solutions exceeded 160.
Update: 1 hour before the end of the competition - 200 solutions.
Update: 7 minutes to the end - arrives on 3-5 solutions per minute
Update: The decision has been completed, 265 decisions have been received (with duplicates). Results table, source codes of winners, error analysis - everything will be published on January 2nd (I hope to be in time) in a separate article in the same hubs.
Update: 183 solutions without re-sending.
Update: 42 participants sent the file main.cpp
Update: 162 solutions compiled the first time, I expected much worse.
Update: 164 solutions compiled, 1 fell victim to C ++ 11, 18 - the victim of more more prose errors.
Update: Simple tests (1, 10, 1000, 100000, 1000000) passed 109 solutions, 47 gave incorrect answers (including crashes), 8 did not have time to give an answer in a minute (an example of a solution from the article tests 1 million passes in 5 minutes 36 seconds ).
Update: Complicated tests are completed, 91 solutions passed all tests at the set time, 5 - with incorrect answers, 13 - did not meet the minute per test. Solution time was measured with microsecond accuracy, and the average was taken based on the results of 4 different tests. Formed a table of results.
Update: For top-3 tests were repeated 100 times (time was summed up for greater accuracy) - the result did not change.

Source: https://habr.com/ru/post/164515/


All Articles