时间复杂度:1秒内能执行多少指令

1秒内大概能执行1e8条执行,也就是在O(N^2)的时间复杂度下,N应该小于1万(1e4)
#include <iostream>

using namespace std;

int main(){
    int i,j,a=0;
    for(i=0;i<10000;i++)
        for(j=0;j<10000;j++)
            a++;
    return 0;
}

9!=362880 ≈ 4*10^5

10!≈ 4*10^6

11!≈ 4*10^7 (极限)

12!≈5*10^8  (约5秒,12个元素全排列)

 
原文地址:https://www.cnblogs.com/TQCAI/p/8650958.html