結果

問題 No.546 オンリー・ワン
ユーザー ckawatak
提出日時 2017-10-18 20:39:29
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 491 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 88,596 KB
最終ジャッジ日時 2024-11-18 15:00:49
合計ジャッジ時間 2,566 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

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

from functools import reduce
from fractions import gcd
from itertools import combinations

def lcm(*numbers):
    def lcm(a, b):
        return (a * b) // gcd(a, b)
    return reduce(lcm, numbers, 1)

def pie(n, cs):
    total = 0
    for i in range(1, len(cs)+1):
        for c in combinations(cs, i):
            total += pow(-1, i-1) * i * (n//lcm(*c))
    return total

print(pie(H, CS) - pie(L-1, CS))
0