結果
| 問題 |
No.546 オンリー・ワン
|
| コンテスト | |
| ユーザー |
sue_charo
|
| 提出日時 | 2017-07-15 00:16:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 1,533 bytes |
| コンパイル時間 | 675 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-10-08 00:20:17 |
| 合計ジャッジ時間 | 1,319 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}
def read():
N, L, H = ILI()
C = ILI()
return N, L, H, C
def calc_div(low, high, div_num):
low_div, low_mod = divmod(low, div_num)
high_div = high // div_num
if low_mod != 0:
low_div += 1
return high_div - low_div + 1
def gcd(a, b):
while b:
a, b = b, a % b
return a
def lcm(a, b):
return a * b // gcd (a, b)
def l_lcm(list):
if len(list) == 0:
return 0
elif len(list) == 1:
return list[0]
elif len(list) == 2:
return lcm(list[0], list[1])
else:
ret_lcm = lcm(list[0], list[1])
for i in range(2, len(list)):
ret_lcm = lcm(ret_lcm, list[i])
return ret_lcm
def solve(N, L, H, C):
ans = 0
comb_num = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]
for i in range(1, N + 1):
sum_div_num = 0
for comb in itertools.combinations(C, i):
comb_lcm = l_lcm(comb)
div_num = calc_div(L, H, comb_lcm)
sum_div_num += div_num
ans += sum_div_num * comb_num[i - 1]
return ans
def main():
params = read()
print(solve(*params))
if __name__ == "__main__":
main()
sue_charo