結果
問題 | No.546 オンリー・ワン |
ユーザー |
![]() |
提出日時 | 2020-06-28 19:09:00 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 443 bytes |
コンパイル時間 | 104 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-08 00:44:29 |
合計ジャッジ時間 | 920 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
from functools import reduce from itertools import combinations n, L, H = map(int, input().split()) A = list(map(int, input().split())) def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a*(b//gcd(a, b)) ans = 0 for k in range(1, n+1): for subset in combinations(A, k): x = reduce(lcm, subset) ans += H//x*(-1)**(k-1)*k ans -= (L-1)//x*(-1)**(k-1)*k print(ans)