Submission #74412
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; bool roland[n + 1] = {}; //trueだったら素数じゃない roland[0] = true ; roland[1] = true ; for ( int i = 3; i * i < n; i += 2) { if (!roland[i]) { for ( int j = i + i; j <= n; j += i) { roland[j] = true ; } } } cout << 2 << "\n" ; for ( int i = 3; i <= n; i += 2) { if (!roland[i]) { cout << i << "\n" ; } } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0437 - 素数 |
ユーザー名 | woody_1227 |
投稿日時 | 2023-07-11 16:17:01 |
言語 | C++17 |
状態 | Accepted |
得点 | 4 |
ソースコード長 | 549 Byte |
最大実行時間 | 24 ms |
最大メモリ使用量 | 1360 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 4 / 4 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
sosu_input01 | AC | 21 ms | 604 KB |
1
|
sosu_input02 | AC | 21 ms | 444 KB |
1
|
sosu_input03 | AC | 23 ms | 412 KB |
1
|
sosu_input04 | AC | 15 ms | 508 KB |
1
|
sosu_input05 | AC | 24 ms | 1360 KB |
1
|