結果
問題 | No.546 オンリー・ワン |
ユーザー |
![]() |
提出日時 | 2025-03-17 21:04:40 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 57 ms / 2,000 ms |
コード長 | 450 bytes |
コンパイル時間 | 553 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 69,164 KB |
最終ジャッジ日時 | 2025-03-17 21:04:42 |
合計ジャッジ時間 | 1,903 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
from itertools import combinations from math import lcm def f(n, vs: list[int]): res = 0 for i in range(1, len(vs)+1): for cs in combinations(vs, i): x = 1 for v in cs: x = lcm(x, v) sgn = 1 if i % 2 == 1 else -1 res += sgn * (n // x) * i return res N, L, H = map(int, input().split()) C = list(map(int, input().split())) ans = f(H, C) - f(L-1, C) print(ans)