Why is Python faster than C++ in this example?

Revision en3, by s3yoonpark, 2023-04-30 22:53:51

So I am solving question 3 from here https://www.olympiad.org.uk/papers/2016/bio/bio16-exam.pdf

I have two pieces of code, one in Python and one in C++. (Both attached below as pictures)

Although the both pieces of code seem to be employing the same logic, the Python one seems to be a lot faster than C++.

An example test case could be -> 614700 3643 90149 -> (It should output 18)

Please can someone tell me why this is the case?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English s3yoonpark 2023-04-30 22:58:42 92 (published)
en3 English s3yoonpark 2023-04-30 22:53:51 0 Added Images (saved to drafts)
en2 English s3yoonpark 2023-04-30 22:49:17 1
en1 English s3yoonpark 2023-04-30 22:48:49 503 Initial revision (published)