結果

問題 No.144 エラトステネスのざる
ユーザー nephrologistnephrologist
提出日時 2021-01-28 00:14:05
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 526 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 79,660 KB
最終ジャッジ日時 2023-09-07 06:59:16
合計ジャッジ時間 4,405 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,608 KB
testcase_01 AC 71 ms
71,388 KB
testcase_02 AC 71 ms
71,616 KB
testcase_03 AC 77 ms
71,568 KB
testcase_04 AC 72 ms
71,212 KB
testcase_05 AC 73 ms
71,456 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

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 = mx.bit_length()
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)
0