結果
| 問題 | No.546 オンリー・ワン | 
| コンテスト | |
| ユーザー |  maspy | 
| 提出日時 | 2020-03-03 23:00:31 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 32 ms / 2,000 ms | 
| コード長 | 612 bytes | 
| コンパイル時間 | 76 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-10-13 23:22:05 | 
| 合計ジャッジ時間 | 1,043 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 7 | 
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from math import gcd
# %%
N, L, H, *C = map(int, read().split())
# %%
def lcm(x, y):
    return x * (y // gcd(x, y))
def f(H):
    LCM = [1]
    for x in C:
        LCM += [lcm(x, y) for y in LCM]
    A = [H // x for x in LCM]
    for i in range(N):
        for n in range(1 << N):
            if n & (1 << i):
                continue
            A[n] -= A[n ^ (1 << i)]
    return sum(A[1 << i] for i in range(N))
# %%
answer = f(H) - f(L - 1)
print(answer)
            
            
            
        