結果
問題 |
No.144 エラトステネスのざる
|
ユーザー |
|
提出日時 | 2015-03-08 18:11:28 |
言語 | C90 (gcc 12.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 483 bytes |
コンパイル時間 | 529 ms |
コンパイル使用メモリ | 22,528 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 16:09:00 |
合計ジャッジ時間 | 4,133 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | AC * 3 RE * 14 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d %f", &n, &p); | ^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int n, x, i; float p, mean = 0; float list_of_koho[n+1]; float list_of_sosu[n+1]; scanf("%d %f", &n, &p); for (i = 2; i <= n; i++) { list_of_koho[i] = 1; list_of_sosu[i] = 0; } for (x = 2; x <= n; x++) { list_of_sosu[x] = list_of_koho[x]; list_of_koho[x] = 0; for (i = 2; x*i <= n; i++) list_of_koho[x*i] -= list_of_koho[x*i] * p; } for (i = 2; i <= n; i++) mean += list_of_sosu[i]; printf("%f\n", mean); return 0; }