結果

問題 No.546 オンリー・ワン
ユーザー gr1msl3ygr1msl3y
提出日時 2022-08-30 00:03:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 65,024 KB
最終ジャッジ日時 2024-04-24 12:39:31
合計ジャッジ時間 1,236 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 42 ms
51,712 KB
testcase_02 AC 40 ms
51,968 KB
testcase_03 AC 41 ms
52,480 KB
testcase_04 AC 39 ms
52,480 KB
testcase_05 AC 39 ms
52,352 KB
testcase_06 AC 40 ms
52,864 KB
testcase_07 AC 51 ms
62,464 KB
testcase_08 AC 55 ms
64,256 KB
testcase_09 AC 56 ms
65,024 KB
testcase_10 AC 56 ms
64,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
N, L, H = map(int, input().split())
C = list(map(int, input().split()))
MOD = 10**9+7
A = [1]*(1 << N)
INF = 2*10**9
ans = 0
for i in range(1 << N):
    f = 0
    for j in range(N):
        if (i >> j) & 1:
            f += 1
            continue
        ni = i ^ (1 << j)
        A[ni] = min(INF, A[i]*C[j]//gcd(A[i], C[j]))
    v = H//A[i]
    ans += v*f if f % 2 else -v*f

for i in range(1 << N):
    f = 0
    for j in range(N):
        if (i >> j) & 1:
            f += 1
            continue
    v = (L-1)//A[i]
    ans += v*f if not f % 2 else -v*f

print(ans)
0