結果

問題 No.546 オンリー・ワン
ユーザー 👑 rin204rin204
提出日時 2022-07-14 13:02:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 413 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 76,872 KB
最終ジャッジ日時 2023-09-08 03:00:19
合計ジャッジ時間 2,113 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,444 KB
testcase_01 AC 69 ms
71,744 KB
testcase_02 AC 68 ms
71,456 KB
testcase_03 AC 67 ms
71,740 KB
testcase_04 AC 68 ms
71,824 KB
testcase_05 AC 68 ms
71,428 KB
testcase_06 AC 69 ms
71,208 KB
testcase_07 AC 79 ms
76,816 KB
testcase_08 AC 79 ms
76,548 KB
testcase_09 AC 83 ms
76,772 KB
testcase_10 AC 82 ms
76,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

n, l, h = map(int, input().split())
C = list(map(int, input().split()))
ans = 0
for bit in range(1, 1 << n):
    x = 1
    cnt = 0
    for i in range(n):
        if bit >> i & 1:
            cnt += 1
            x = x * C[i] // gcd(x, C[i])
    mi = (l + x - 1) // x
    ma = h // x
    if cnt & 1:
        ans += (ma - mi + 1) * cnt
    else:
        ans -= (ma - mi + 1) * cnt
print(ans)

0