Loop runs for 10^18 and still executes : Strange Behaviour or am too dumb to understand this?

Правка en1, от njha1999, 2020-02-01 00:06:44

Either this is something strangely deep or i have to revisit time complexity analysis for a piece of code !!

#include <iostream>
int main()
{
    long long int t=1e18,a=0; 

    while(t--) a++;
    std::cout<<a;
    return 0;
}

This code executes in 15 ms codeforces / codechef ide! How is that even possible?

May be this question is too dumb but any help is appreciated. Thanks!

Теги #running time, time complexity

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский njha1999 2020-02-01 00:06:44 513 Initial revision (published)