結果

問題 No.546 オンリー・ワン
ユーザー NoaSaberNoaSaber
提出日時 2021-05-10 10:25:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 81,420 KB
実行使用メモリ 63,800 KB
最終ジャッジ日時 2023-10-19 18:52:50
合計ジャッジ時間 2,926 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,668 KB
testcase_01 AC 37 ms
53,668 KB
testcase_02 AC 37 ms
53,604 KB
testcase_03 AC 37 ms
53,668 KB
testcase_04 AC 38 ms
53,604 KB
testcase_05 AC 38 ms
53,668 KB
testcase_06 AC 38 ms
53,668 KB
testcase_07 AC 38 ms
53,668 KB
testcase_08 AC 45 ms
59,692 KB
testcase_09 AC 49 ms
61,760 KB
testcase_10 AC 49 ms
63,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0