結果
| 問題 | No.546 オンリー・ワン | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-05-10 10:25:19 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 45 ms / 2,000 ms | 
| コード長 | 570 bytes | 
| コンパイル時間 | 1,700 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 62,464 KB | 
| 最終ジャッジ日時 | 2024-09-19 15:09:03 | 
| 合計ジャッジ時間 | 2,007 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
import math
N,L,H=map(int,input().split())
C=list(map(int,input().split()))
import itertools
def comb(N,C):
    return math.factorial(N)//(math.factorial(C)*math.factorial(N-C))
def lcm(leng,l):
    if leng==1:
        return l[0]
    lcm_all=l[0]
    for _ in range(leng-1):
        lcm_all=lcm_all*l[_+1]//math.gcd(lcm_all,l[_+1])
    return lcm_all
ans=0
for i in range(1,N+1):
    for j in itertools.combinations(C,i):
        tmp=lcm(len(j),j)
        if i%2==0:
            ans-=(H//tmp-(L-1)//tmp)*i
        else:
            ans+=(H//tmp-(L-1)//tmp)*i
print(ans)
            
            
            
        