結果
問題 | No.144 エラトステネスのざる |
ユーザー | nephrologist |
提出日時 | 2021-01-28 00:15:43 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 533 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 86,968 KB |
実行使用メモリ | 81,900 KB |
最終ジャッジ日時 | 2023-09-07 07:04:10 |
合計ジャッジ時間 | 5,284 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
76,040 KB |
testcase_01 | AC | 72 ms
71,628 KB |
testcase_02 | AC | 71 ms
71,684 KB |
testcase_03 | AC | 73 ms
71,552 KB |
testcase_04 | AC | 72 ms
71,736 KB |
testcase_05 | AC | 71 ms
71,844 KB |
testcase_06 | AC | 81 ms
75,696 KB |
testcase_07 | AC | 82 ms
75,764 KB |
testcase_08 | AC | 80 ms
75,652 KB |
testcase_09 | AC | 79 ms
75,652 KB |
testcase_10 | AC | 78 ms
75,792 KB |
testcase_11 | AC | 78 ms
75,760 KB |
testcase_12 | AC | 81 ms
75,712 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
n, p = input().split() n = int(n) p = float(p) def divide(n): res = 0 for i in range(1, int(n ** 0.5) + 1): if n % i == 0: if i * i == n: res += 1 else: res += 2 return res mx = 10 ** 6 num = int(mx ** (1 / 2) + 1) prod = [1] * (num + 10) q = 1 - p for i in range(num + 5): prod[i + 1] = prod[i] * q ans = 0 for i in range(2, n + 1): yakusu = divide(i) if yakusu == 2: ans += 1 else: ans += prod[yakusu - 2] print(ans)