Submission #79219
ソースコード
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<stdio.h> int main(){ long long n; scanf ( "%lld" ,&n); long long a[n+1]; for ( int c=0; c<=n; c++){ a[c]=1; } a[0]=0; a[1]=0; for ( int c=2; c<=n; c++){ if (a[c]==1){ for ( int i=c*2; i<=n; i+=c){ a[i]=0; } } } for ( int c=2; c<=n; c++){ if (a[c]==1){ printf ( "%lld\n" ,c); } } return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0437 - 素数 |
ユーザー名 | ei2437 |
投稿日時 | 2024-05-25 15:10:25 |
言語 | C |
状態 | Accepted |
得点 | 4 |
ソースコード長 | 447 Byte |
最大実行時間 | 28 ms |
最大メモリ使用量 | 4516 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 4 / 4 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
sosu_input01 | AC | 26 ms | 504 KB |
1
|
sosu_input02 | AC | 19 ms | 312 KB |
1
|
sosu_input03 | AC | 22 ms | 328 KB |
1
|
sosu_input04 | AC | 23 ms | 508 KB |
1
|
sosu_input05 | AC | 28 ms | 4516 KB |
1
|