Submission #79311
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include<stdio.h> int main(){ int n; scanf ( "%d" ,&n); int isnt_sosu[500000+1]={}; //*0=素数,1=素数じゃない isnt_sosu[0]; for ( int i = 0; i < n; i++){ if (n>=1){ isnt_sosu[1]=1; } } for ( int i = 2; i <=n; i++){ if (isnt_sosu[i]==0){ for ( int j = i*2; j <= n; j+=i){ isnt_sosu[j]=1; } } } for ( int i = 2; i <= n; i++){ if (isnt_sosu[i]==0){ printf ( "%d\n" ,i); } } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0437 - 素数 |
ユーザー名 | ei2423 |
投稿日時 | 2024-05-31 15:51:45 |
言語 | C |
状態 | Accepted |
得点 | 4 |
ソースコード長 | 548 Byte |
最大実行時間 | 27 ms |
最大メモリ使用量 | 2616 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 4 / 4 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
sosu_input01 | AC | 27 ms | 2396 KB |
1
|
sosu_input02 | AC | 20 ms | 2164 KB |
1
|
sosu_input03 | AC | 22 ms | 2184 KB |
1
|
sosu_input04 | AC | 20 ms | 2340 KB |
1
|
sosu_input05 | AC | 23 ms | 2616 KB |
1
|