結果

問題 No.546 オンリー・ワン
ユーザー titia
提出日時 2024-03-04 03:43:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-29 17:19:44
合計ジャッジ時間 1,240 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
def lcm(x,y):
    return x*y//gcd(x,y)

N,L,H=map(int,input().split())
C=list(map(int,input().split()))

ANS=0

for i in range(1,1<<N):
    x=1
    count=0
    for j in range(N):
        if i & (1<<j) != 0:
            x=lcm(x,C[j])
            count+=1

    if count%2==1:
        ANS+=(H//x - (L-1)//x)*count
    else:
        ANS-=(H//x - (L-1)//x)*count

print(ANS)
0