結果

問題 No.546 オンリー・ワン
コンテスト
ユーザー rin204
提出日時 2022-07-14 13:02:25
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 413 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 533 ms
コンパイル使用メモリ 85,096 KB
実行使用メモリ 65,112 KB
最終ジャッジ日時 2026-03-12 05:58:04
合計ジャッジ時間 1,521 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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