結果

問題 No.546 オンリー・ワン
ユーザー fiord
提出日時 2017-07-19 15:01:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 68,096 KB
最終ジャッジ日時 2024-10-08 14:20:37
合計ジャッジ時間 1,567 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n, l, h = map(int, input().split())
l -= 1
c = list(map(int, input().split()))
ret = 0
m = 1 << n
for i in range(1, m):
    cnt = bin(i).count("1")
    g = 1
    for j in range(n):
        if (i >> j) & 1:
            g = int(g * c[j] / math.gcd(g, c[j]))
    add = (int(h / g) - int(l / g)) * cnt * (-1)**(cnt & 1 ^ 1)
    ret += add
print(ret)
0