結果

問題 No.144 エラトステネスのざる
ユーザー FromBooskaFromBooska
提出日時 2023-02-15 13:15:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 546 bytes
コンパイル時間 677 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 76,212 KB
最終ジャッジ日時 2023-09-24 22:37:23
合計ジャッジ時間 5,863 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,416 KB
testcase_01 AC 76 ms
71,160 KB
testcase_02 AC 98 ms
71,356 KB
testcase_03 AC 74 ms
71,292 KB
testcase_04 AC 76 ms
71,164 KB
testcase_05 AC 77 ms
71,468 KB
testcase_06 AC 90 ms
76,120 KB
testcase_07 AC 85 ms
75,856 KB
testcase_08 AC 85 ms
76,212 KB
testcase_09 AC 85 ms
75,960 KB
testcase_10 AC 87 ms
76,204 KB
testcase_11 AC 86 ms
75,868 KB
testcase_12 AC 88 ms
75,920 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, exe_prob = map(float, input().split())
N = int(N)

def divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

is_prime = [1] * (N+1)
is_prime[0], is_prime[1] = 0, 0

for i in range(2, N+1):
    divs = divisors(i)[1:-1]
    is_prime[i] = ((1-exe_prob)**len(divs))
            
#print(is_prime)
print(sum(is_prime))
0