my first c++ program runtime is super long like 5 – 10 minutes on a fast CPU it's a very basic c++ program [closed]

This seems like it was purposefully un-optimized. I would assume that the time constraints are coming from modding a variable 100,000,000,000 times. But wait, that is not all. Not only do you mod a variable that many times, but when a variable modded to 0, you iterate another 11 times over each char in “Hello World!”, or, more precisely, 389 times. That means that the last for loop needs to have done at least 100,000,004,279 calculations. How about you just remove that last for loop, because it seems useless other than to kill time, you’d be better off just doing a sleep(5).

Leave a Comment