結果
| 問題 | No.546 オンリー・ワン | 
| コンテスト | |
| ユーザー |  brthyyjp | 
| 提出日時 | 2021-12-08 14:33:03 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 75 ms / 2,000 ms | 
| コード長 | 518 bytes | 
| コンパイル時間 | 188 ms | 
| コンパイル使用メモリ | 82,512 KB | 
| 実行使用メモリ | 70,784 KB | 
| 最終ジャッジ日時 | 2024-07-16 06:14:28 | 
| 合計ジャッジ時間 | 1,611 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n, l, h = map(int, input().split())
C = list(map(int, input().split()))
ans = 0
for i in range(1<<n):
    X = []
    for j in range(n):
        if (i>>j)&1:
            X.append(C[j])
    if not X:
        continue
    y = lcm_list(X)
    cnt = h//y-(l-1)//y
    if len(X)%2 == 0:
        ans -= cnt*len(X)
    else:
        ans += cnt*len(X)
print(ans)
            
            
            
        