int m = sqrt(n + 0.5); memset(vis, 0, sizeof(vis)); for(int i = 2; i <= m; i++) if(!vis[i]) for(int j = i * i; j <= n; j += i) vis[j] = 1;
素数筛法
原文:https://www.cnblogs.com/hanasaki/p/10996491.html