結果

問題 No.144 エラトステネスのざる
ユーザー nephrologistnephrologist
提出日時 2021-01-28 00:26:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 85,020 KB
最終ジャッジ日時 2023-09-07 07:12:58
合計ジャッジ時間 3,911 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,612 KB
testcase_01 AC 74 ms
71,340 KB
testcase_02 AC 76 ms
71,416 KB
testcase_03 AC 74 ms
71,148 KB
testcase_04 AC 75 ms
71,604 KB
testcase_05 AC 74 ms
71,376 KB
testcase_06 AC 81 ms
76,336 KB
testcase_07 AC 81 ms
76,312 KB
testcase_08 AC 80 ms
76,092 KB
testcase_09 AC 80 ms
76,564 KB
testcase_10 AC 80 ms
76,088 KB
testcase_11 AC 81 ms
76,484 KB
testcase_12 AC 80 ms
76,492 KB
testcase_13 AC 207 ms
84,796 KB
testcase_14 AC 202 ms
84,980 KB
testcase_15 AC 192 ms
84,884 KB
testcase_16 AC 194 ms
84,700 KB
testcase_17 AC 193 ms
84,948 KB
testcase_18 AC 194 ms
85,020 KB
testcase_19 AC 193 ms
84,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
#     ans += prod[yakusu - 2]
# print(ans)

cnt = [0] * (n + 1)

for i in range(2, n + 1):
    for j in range(n // i + 1):
        if i * (j + 1) <= n:
            cnt[i * (j + 1)] += 1

for i in range(2, n + 1):
    ans += prod[cnt[i] - 1]

print(ans)
0