Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

What is the estimated complexity of this program?
Разница между en1 и en2, 0 символ(ов) изменены
```cpp↵
int n;↵
cin>>n;↵
if (n==0)//deal with it↵
for (double i=0;i<=1/(double)n;i+=1e-9)//do something↵
```↵

It seems that, this code runs faster when $n$ becomes larger...↵

When $n=10^9$, the code will be executed once. When $n=1$, it runs $10^9$ times.↵

So I estimated it as $O(n^{-1})$.↵

But, this means that this algorithm runs even faster than $O(1)$.↵

How is it possible?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский LilyWhite 2019-01-29 13:54:39 0 (published)
en1 Английский LilyWhite 2019-01-29 13:54:00 437 Initial revision (saved to drafts)