結果

問題 No.546 オンリー・ワン
ユーザー maspymaspy
提出日時 2020-03-03 23:00:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-22 00:49:22
合計ジャッジ時間 922 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 25 ms
10,752 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 AC 25 ms
10,752 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 29 ms
10,752 KB
testcase_10 AC 29 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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)
0