結果
問題 | No.144 エラトステネスのざる |
ユーザー | cherrypi59 |
提出日時 | 2018-06-23 12:50:39 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 460 bytes |
コンパイル時間 | 115 ms |
コンパイル使用メモリ | 10,564 KB |
実行使用メモリ | 12,364 KB |
最終ジャッジ日時 | 2023-09-13 08:19:50 |
合計ジャッジ時間 | 4,238 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,016 KB |
testcase_01 | AC | 16 ms
7,864 KB |
testcase_02 | AC | 16 ms
7,872 KB |
testcase_03 | AC | 17 ms
7,968 KB |
testcase_04 | AC | 17 ms
7,808 KB |
testcase_05 | AC | 17 ms
7,784 KB |
testcase_06 | AC | 18 ms
7,864 KB |
testcase_07 | AC | 19 ms
7,804 KB |
testcase_08 | AC | 19 ms
7,924 KB |
testcase_09 | AC | 19 ms
7,812 KB |
testcase_10 | AC | 19 ms
7,860 KB |
testcase_11 | AC | 18 ms
7,864 KB |
testcase_12 | AC | 19 ms
7,824 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
def div(x, p): z, idx, cnt = 0, 2, 0 while idx * idx <= x: if x % idx == 0: z += p * (1-p) ** cnt cnt += 1 if x // idx != idx: z += p * (1 - p) ** cnt cnt += 1 idx += 1 return z def main(): n, p = map(float, input().split()) num = 0 for i in range(2, int(n)+1): num += div(i, p) print(n-1-num) if __name__ == '__main__': main()