problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
luogu::P5736类 参考

洛谷 P5736 【深基7.例2】质数筛 更多...

#include <luogu.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

洛谷 P5736 【深基7.例2】质数筛

在文件 luogu.h599 行定义.

成员函数说明

◆ main()

int luogu::P5736::main ( istream &  cin,
ostream &  cout 
)
static

在文件 luogu.cpp2273 行定义.

2273 {
2274 int n;
2275 cin >> n;
2276 bool notprime[100001];
2277 memset(notprime, 1, sizeof notprime);
2278 notprime[0] = false;
2279 notprime[1] = false;
2280 notprime[2] = true;
2281 for(unsigned int i = 2; i <= 50000; i++) {
2282 for(unsigned int j = 2; i * j <= 100000; j++) {
2283 notprime[i * j] = false;
2284 }
2285 }
2286 unsigned int num;
2287 for(int _ = 0; _ < n; _++) {
2288 cin >> num;
2289 if(notprime[num]) {
2290 cout << num << " ";
2291 }
2292 }
2293 return 0;
2294 }

被这些函数引用 luogu::TEST().


该类的文档由以下文件生成: