結果

問題 No.546 オンリー・ワン
ユーザー brthyyjpbrthyyjp
提出日時 2021-12-08 14:33:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 78,128 KB
最終ジャッジ日時 2023-09-23 06:19:41
合計ジャッジ時間 2,501 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
72,524 KB
testcase_01 AC 107 ms
72,628 KB
testcase_02 AC 108 ms
72,396 KB
testcase_03 AC 109 ms
72,400 KB
testcase_04 AC 109 ms
72,488 KB
testcase_05 AC 111 ms
72,404 KB
testcase_06 AC 110 ms
72,556 KB
testcase_07 AC 120 ms
77,944 KB
testcase_08 AC 124 ms
77,832 KB
testcase_09 AC 130 ms
78,068 KB
testcase_10 AC 132 ms
78,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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