結果

問題 No.546 オンリー・ワン
ユーザー ooaiu
提出日時 2025-09-17 03:02:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 76,648 KB
最終ジャッジ日時 2025-09-17 03:02:44
合計ジャッジ時間 1,993 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

N,L,H=map(int,input().split())
A=list(map(int,input().split()))
def gcd(a,b):
    return a if b == 0 else gcd(b, a%b)
ans = 0
for bit in range(1,1<<N):
    l = 1
    t = 0
    for i in range(N):
        if bit >> i & 1:
            t += 1
            l = l//gcd(l,A[i])*A[i]
    x = H//l - (L-1)//l
    if t % 2 == 0:
        x = -x
    ans += t * x
print(ans)
0