結果

問題 No.546 オンリー・ワン
ユーザー rlangevinrlangevin
提出日時 2023-07-10 12:39:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 77,076 KB
最終ジャッジ日時 2023-10-10 01:10:28
合計ジャッジ時間 2,186 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,396 KB
testcase_01 AC 77 ms
71,516 KB
testcase_02 AC 76 ms
71,404 KB
testcase_03 AC 77 ms
71,568 KB
testcase_04 AC 77 ms
71,516 KB
testcase_05 AC 74 ms
71,520 KB
testcase_06 AC 76 ms
71,320 KB
testcase_07 AC 74 ms
71,316 KB
testcase_08 AC 83 ms
77,076 KB
testcase_09 AC 82 ms
76,964 KB
testcase_10 AC 83 ms
76,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import lcm

def popcount(n):
    cnt = 0
    while n:
        cnt += n & 1
        n >>= 1
    return cnt

N, L, H = map(int, input().split())
C = list(map(int, input().split()))
ans = 0
N2 = 1 << N
for s in range(1, N2):
    cnt = 0
    val = 1
    for i in range(N):
        if (s >> i) & 1:
            cnt += 1
            val = lcm(val, C[i])
            if val > H:
                break
    ans += (H//val - (L - 1)//val) * (-1) ** (cnt + 1) * cnt
print(ans)
0