from itertools import product, combinations_with_replacement import time import threading from collections import defaultdict import math # 配置参数(可根据需要修改) TARGET = 24660 # 目标值 BASE_VALUES = [36.5, 41.5, 59,68.5, 74, 91.5] # 基础系数列表 FLUCTUATION = 1.0 # 系数波动范围 MAX_SOLUTIONS = 3 # 每个组合的最大解数量 SOLVER_TIMEOUT = 180 # 求解超时时间(秒) THREE_VAR_THRESHOLD = 220000 # 使用三个变量的阈值 PRODUCT_RANGE_THRESHOLD = 148000 # 乘积范围限制阈值 HIGH_TARGET_THRESHOLD = 260000 # 更高目标值阈值 SHOW_PROGRESS = True # 是否显示进度 MAX_SOLUTIONS_PER_COMB = 100 # 每个组合的最大解数量,用于提前终止 def is_valid_product(p): """检查单个乘积是否在有效范围内""" if TARGET > PRODUCT_RANGE_THRESHOLD: if TARGET > HIGH_TARGET_THRESHOLD: return p <= 115000 # 目标值超过260000时,仅限制最大值 else: return 74000 <= p <= 115000 # 目标值在148000-260000之间时,使用原范围 else: return True # 目标值较小时不限制乘积范围 def find_single_variable_solutions(values): """查找单个数的解(a*x = TARGET)""" solutions = [] for a in values: x = TARGET / a if x.is_integer() and 1 <= x <= 10000 and is_valid_product(a * x): solutions.append((a, x)) if len(solutions) >= MAX_SOLUTIONS: return solutions # 提前终止 return solutions def find_two_variable_solutions(values): """查找两个变量的解(a*x + b*y = TARGET)""" solutions = defaultdict(list) # 生成所有可能的(a, b)组合 for a in values: for b in values: if a == b: # 避免重复 continue # 计算x的有效范围 if max_x < min_x: continue for x in range(min_x, max_x + 1): remainder = TARGET - a * x # 检查remainder是否在可能的范围内 if remainder < 1 or remainder > b * 10000: continue # 检查remainder是否能被b整除 if remainder % b == 0: y = remainder // b if 1 <= y <= 10000 and is_valid_product(b * y): solutions[(a, b)].append((a, x, b, y)) if len(solutions[(a, b)]) >= MAX_SOLUTIONS_PER_COMB: break # 提前终止当前组合的搜索 return solutions def find_three_variable_solutions(values): """优化的三变量求解算法""" solutions = defaultdict(list) # 对系数进行排序,便于剪枝 sorted_values = sorted(values) # 预计算每个系数的有效范围 value_ranges = {} for a in sorted_values: if TARGET > PRODUCT_RANGE_THRESHOLD: if TARGET > HIGH_TARGET_THRESHOLD: else: else: min_x = 1 max_x = 10000 value_ranges[a] = (min_x, max_x) total_combinations = len(sorted_values) * (len(sorted_values) - 1) * (len(sorted_values) - 2) // 6 processed_combinations = 0 # 三重循环,但添加了更多剪枝条件 for i, a in enumerate(sorted_values): min_x, max_x = value_ranges[a] # 计算可能的x值数量,决定步长 x_count = max_x - min_x + 1 x_step = max(1, x_count // 1000) # 自适应步长 for x in range(min_x, max_x + 1, x_step): ax = a * x if not is_valid_product(ax): continue remainder1 = TARGET - ax if TARGET > PRODUCT_RANGE_THRESHOLD: if TARGET > HIGH_TARGET_THRESHOLD: if remainder1 < 0: continue else: if remainder1 < 2 * 74000: continue # 限制b的选择范围,避免重复组合 for j in range(i + 1, len(sorted_values)): b = sorted_values[j] if TARGET > PRODUCT_RANGE_THRESHOLD: if TARGET > HIGH_TARGET_THRESHOLD: else: else: min_y = 1 if max_y < min_y: continue # 计算可能的y值数量,决定步长 y_count = max_y - min_y + 1 y_step = max(1, y_count // 100) # 自适应步长 for y in range(min_y, max_y + 1, y_step): by = b * y if not is_valid_product(by): continue remainder2 = remainder1 - by if TARGET > PRODUCT_RANGE_THRESHOLD: if TARGET > HIGH_TARGET_THRESHOLD: if remainder2 < 0 or remainder2 > 115000: continue else: if remainder2 < 74000 or remainder2 > 115000: continue # 限制c的选择范围 found_solution = False for k in range(j + 1, len(sorted_values)): c = sorted_values[k] # 检查remainder2是否能被c整除 if remainder2 % c != 0: continue z = remainder2 // c if 1 <= z <= 10000 and is_valid_product(c * z): key = (a, b, c) solutions[key].append((a, x, b, y, c, z)) found_solution = True if len(solutions[key]) >= MAX_SOLUTIONS_PER_COMB: break # 提前终止当前组合的搜索 # 如果找到解且达到最大数量,跳出y循环 if found_solution and len(solutions[key]) >= MAX_SOLUTIONS_PER_COMB: break # 跳出y循环 # 进度显示 if SHOW_PROGRESS and j % 10 == 0: print(f"\r三变量组合进度: {processed_combinations}/{total_combinations} 组", end='') processed_combinations += 1 if SHOW_PROGRESS: print(f"\r三变量组合进度: {processed_combinations}/{total_combinations} 组 - 完成") return solutions def find_balanced_solutions(solutions, var_count, num=2): """从所有解中筛选出最平衡的解""" if var_count == 1 or not solutions: return solutions # 单变量或无解时直接返回 # 当目标值超过220000时,不计算平衡解 if TARGET > THREE_VAR_THRESHOLD: return [] # 计算解的平衡性(变量间差异最小) balanced = [] for sol in solutions: vars = sol[1::2] # 提取x, y, z diff = max(vars) - min(vars) balanced.append((diff, sol)) # 按差异排序,取前num个 return [s for _, s in sorted(balanced, key=lambda x: x[0])[:num]] def find_original_solutions(solutions, balanced_solutions, num=3): """从剩余解中获取原始顺序的解""" if not solutions: return [] # 排除已在平衡解中的项 remaining = [s for s in solutions if s not in balanced_solutions] return remaining[:num] def display_solutions(solutions_dict, var_count): """优化的解显示函数""" if not solutions_dict: return print(f"\n找到 {len(solutions_dict)} 组{var_count}变量解:") for i, (coeffs, pair_solutions) in enumerate(sorted(solutions_dict.items()), 1): # 当目标值超过220000时,不显示平衡解 if TARGET > THREE_VAR_THRESHOLD: all_display = pair_solutions[:MAX_SOLUTIONS] print_tag = "[原始解]" else: # 计算平衡解和原始解 balanced = find_balanced_solutions(pair_solutions, var_count) original = find_original_solutions(pair_solutions, balanced) all_display = balanced + original if var_count == 1: a = coeffs print(f"\n{i}. 组合: a={a} ({len(pair_solutions)} 个有效解)") elif var_count == 2: a, b = coeffs print(f"\n{i}. 组合: a={a}, b={b} ({len(pair_solutions)} 个有效解)") else: # var_count == 3 a, b, c = coeffs print(f"\n{i}. 组合: a={a}, b={b}, c={c} ({len(pair_solutions)} 个有效解)") for j, sol in enumerate(all_display, 1): if TARGET > THREE_VAR_THRESHOLD: tag = print_tag else: tag = "[平衡解]" if j <= len(balanced) else "[原始解]" if var_count == 1: a, x = sol print(f" {j}. x={x}, a*x={a*x:.1f}, 总和={a*x:.1f} {tag}") elif var_count == 2: a, x, b, y = sol print(f" {j}. x={x}, y={y}, a*x={a*x:.1f}, b*y={b*y:.1f}, 总和={a*x + b*y:.1f} {tag}") else: # var_count == 3 a, x, b, y, c, z = sol print(f" {j}. x={x}, y={y}, z={z}, " f"a*x={a*x:.1f}, b*y={b*y:.1f}, c*z={c*z:.1f}, " f"总和={a*x + b*y + c*z:.1f} {tag}") def run_with_timeout(func, args=(), kwargs=None, timeout=SOLVER_TIMEOUT): """运行函数并设置超时限制""" if kwargs is None: kwargs = {} result = [] error = [] def wrapper(): try: result.append(func(*args, **kwargs)) except Exception as e: error.append(e) thread = threading.Thread(target=wrapper) thread.daemon = True thread.start() thread.join(timeout) if thread.is_alive(): print(f"警告: {func.__name__} 超时({timeout}秒),跳过此方法") return None if error: return result[0] def main(): print(f"目标值: {TARGET}") # 生成波动后的系数 FLUCTUATED_VALUES = [round(v - FLUCTUATION, 1) for v in BASE_VALUES] # 尝试基础系数 print(f"\n==== 尝试基础系数 ====") # 检查目标值是否超过阈值 if TARGET > THREE_VAR_THRESHOLD: print(f"目标值 {TARGET} 超过阈值 {THREE_VAR_THRESHOLD},只尝试三变量解") base_solutions = { 'single': [], 'two': [], 'three': run_with_timeout(find_three_variable_solutions, args=(BASE_VALUES,)) } # 显示三变量解 if base_solutions['three'] and len(base_solutions['three']) > 0: display_solutions(base_solutions['three'], 3) print(f"\n使用基础系数列表,共找到有效解") return else: print("\n基础系数三变量无解,尝试波动系数") else: # 目标值未超过阈值,按顺序尝试单、双、三变量解 base_solutions = { 'single': run_with_timeout(find_single_variable_solutions, args=(BASE_VALUES,)), 'two': run_with_timeout(find_two_variable_solutions, args=(BASE_VALUES,)), 'three': [] } # 检查是否有解 has_solution = False # 显示单变量解 if base_solutions['single']: has_solution = True display_solutions({a: [sol] for a, sol in zip(BASE_VALUES, base_solutions['single']) if sol}, 1) # 显示双变量解 if base_solutions['two'] and len(base_solutions['two']) > 0: has_solution = True display_solutions(base_solutions['two'], 2) # 单变量和双变量都无解时,尝试三变量解 if not has_solution: print(f"\n==== 单变量和双变量无解,尝试三变量解 ====") base_solutions['three'] = run_with_timeout(find_three_variable_solutions, args=(BASE_VALUES,)) if base_solutions['three'] and len(base_solutions['three']) > 0: has_solution = True display_solutions(base_solutions['three'], 3) # 如果找到解,退出程序 if has_solution: print(f"\n使用基础系数列表,共找到有效解") return # 如果基础系数没有找到解,尝试波动系数 print(f"\n==== 尝试波动系数 ====") # 检查目标值是否超过阈值 if TARGET > THREE_VAR_THRESHOLD: print(f"目标值 {TARGET} 超过阈值 {THREE_VAR_THRESHOLD},只尝试三变量解") fluctuated_solutions = { 'single': [], 'two': [], 'three': run_with_timeout(find_three_variable_solutions, args=(FLUCTUATED_VALUES,)) } # 显示三变量解 if fluctuated_solutions['three'] and len(fluctuated_solutions['three']) > 0: display_solutions(fluctuated_solutions['three'], 3) print(f"\n使用波动系数列表,共找到有效解") return else: # 目标值未超过阈值,按顺序尝试单、双、三变量解 fluctuated_solutions = { 'single': run_with_timeout(find_single_variable_solutions, args=(FLUCTUATED_VALUES,)), 'two': run_with_timeout(find_two_variable_solutions, args=(FLUCTUATED_VALUES,)), 'three': [] } # 重置标志 has_solution = False # 显示单变量解 if fluctuated_solutions['single']: has_solution = True display_solutions({a: [sol] for a, sol in zip(FLUCTUATED_VALUES, fluctuated_solutions['single']) if sol}, 1) # 显示双变量解 if fluctuated_solutions['two'] and len(fluctuated_solutions['two']) > 0: has_solution = True display_solutions(fluctuated_solutions['two'], 2) # 单变量和双变量都无解时,尝试三变量解 if not has_solution: print(f"\n==== 单变量和双变量无解,尝试三变量解 ====") fluctuated_solutions['three'] = run_with_timeout(find_three_variable_solutions, args=(FLUCTUATED_VALUES,)) if fluctuated_solutions['three'] and len(fluctuated_solutions['three']) > 0: has_solution = True display_solutions(fluctuated_solutions['three'], 3) # 如果找到解,退出程序 if has_solution: print(f"\n使用波动系数列表,共找到有效解") return # 如果所有系数集都没有找到解 print("\n没有找到符合条件的解,即使使用波动后的系数列表。") if __name__ == "__main__": main() print(f"\n总耗时: {time.time() - start_time:.2f}秒")
Standard input is empty
目标值: 24660 ==== 尝试基础系数 ==== 找到 1 组1变量解: 1. 组合: a=36.5 (1 个有效解) 1. x=360.0, a*x=24660.0, 总和=24660.0 [平衡解] 找到 30 组2变量解: 1. 组合: a=36.5, b=41.5 (8 个有效解) 1. x=297, y=333.0, a*x=10840.5, b*y=13819.5, 总和=24660.0 [平衡解] 2. x=380, y=260.0, a*x=13870.0, b*y=10790.0, 总和=24660.0 [平衡解] 3. x=48, y=552.0, a*x=1752.0, b*y=22908.0, 总和=24660.0 [原始解] 4. x=131, y=479.0, a*x=4781.5, b*y=19878.5, 总和=24660.0 [原始解] 5. x=214, y=406.0, a*x=7811.0, b*y=16849.0, 总和=24660.0 [原始解] 2. 组合: a=36.5, b=59 (6 个有效解) 1. x=202, y=293.0, a*x=7373.0, b*y=17287.0, 总和=24660.0 [平衡解] 2. x=320, y=220.0, a*x=11680.0, b*y=12980.0, 总和=24660.0 [平衡解] 3. x=84, y=366.0, a*x=3066.0, b*y=21594.0, 总和=24660.0 [原始解] 4. x=438, y=147.0, a*x=15987.0, b*y=8673.0, 总和=24660.0 [原始解] 5. x=556, y=74.0, a*x=20294.0, b*y=4366.0, 总和=24660.0 [原始解] 3. 组合: a=36.5, b=68.5 (4 个有效解) 1. x=274, y=214.0, a*x=10001.0, b*y=14659.0, 总和=24660.0 [平衡解] 2. x=137, y=287.0, a*x=5000.5, b*y=19659.5, 总和=24660.0 [平衡解] 3. x=411, y=141.0, a*x=15001.5, b*y=9658.5, 总和=24660.0 [原始解] 4. x=548, y=68.0, a*x=20002.0, b*y=4658.0, 总和=24660.0 [原始解] 4. 组合: a=36.5, b=74 (4 个有效解) 1. x=260, y=205.0, a*x=9490.0, b*y=15170.0, 总和=24660.0 [平衡解] 2. x=112, y=278.0, a*x=4088.0, b*y=20572.0, 总和=24660.0 [平衡解] 3. x=408, y=132.0, a*x=14892.0, b*y=9768.0, 总和=24660.0 [原始解] 4. x=556, y=59.0, a*x=20294.0, b*y=4366.0, 总和=24660.0 [原始解] 5. 组合: a=36.5, b=91.5 (4 个有效解) 1. x=267, y=163.0, a*x=9745.5, b*y=14914.5, 总和=24660.0 [平衡解] 2. x=84, y=236.0, a*x=3066.0, b*y=21594.0, 总和=24660.0 [平衡解] 3. x=450, y=90.0, a*x=16425.0, b*y=8235.0, 总和=24660.0 [原始解] 4. x=633, y=17.0, a*x=23104.5, b*y=1555.5, 总和=24660.0 [原始解] 6. 组合: a=41.5, b=36.5 (8 个有效解) 1. x=333, y=297.0, a*x=13819.5, b*y=10840.5, 总和=24660.0 [平衡解] 2. x=260, y=380.0, a*x=10790.0, b*y=13870.0, 总和=24660.0 [平衡解] 3. x=41, y=629.0, a*x=1701.5, b*y=22958.5, 总和=24660.0 [原始解] 4. x=114, y=546.0, a*x=4731.0, b*y=19929.0, 总和=24660.0 [原始解] 5. x=187, y=463.0, a*x=7760.5, b*y=16899.5, 总和=24660.0 [原始解] 7. 组合: a=41.5, b=59 (5 个有效解) 1. x=226, y=259.0, a*x=9379.0, b*y=15281.0, 总和=24660.0 [平衡解] 2. x=344, y=176.0, a*x=14276.0, b*y=10384.0, 总和=24660.0 [平衡解] 3. x=108, y=342.0, a*x=4482.0, b*y=20178.0, 总和=24660.0 [原始解] 4. x=462, y=93.0, a*x=19173.0, b*y=5487.0, 总和=24660.0 [原始解] 5. x=580, y=10.0, a*x=24070.0, b*y=590.0, 总和=24660.0 [原始解] 8. 组合: a=41.5, b=68.5 (4 个有效解) 1. x=274, y=194.0, a*x=11371.0, b*y=13289.0, 总和=24660.0 [平衡解] 2. x=137, y=277.0, a*x=5685.5, b*y=18974.5, 总和=24660.0 [平衡解] 3. x=411, y=111.0, a*x=17056.5, b*y=7603.5, 总和=24660.0 [原始解] 4. x=548, y=28.0, a*x=22742.0, b*y=1918.0, 总和=24660.0 [原始解] 9. 组合: a=41.5, b=74 (4 个有效解) 1. x=152, y=248.0, a*x=6308.0, b*y=18352.0, 总和=24660.0 [平衡解] 2. x=300, y=165.0, a*x=12450.0, b*y=12210.0, 总和=24660.0 [平衡解] 3. x=4, y=331.0, a*x=166.0, b*y=24494.0, 总和=24660.0 [原始解] 4. x=448, y=82.0, a*x=18592.0, b*y=6068.0, 总和=24660.0 [原始解] 10. 组合: a=41.5, b=91.5 (3 个有效解) 1. x=129, y=211.0, a*x=5353.5, b*y=19306.5, 总和=24660.0 [平衡解] 2. x=312, y=128.0, a*x=12948.0, b*y=11712.0, 总和=24660.0 [平衡解] 3. x=495, y=45.0, a*x=20542.5, b*y=4117.5, 总和=24660.0 [原始解] 11. 组合: a=59, b=36.5 (6 个有效解) 1. x=293, y=202.0, a*x=17287.0, b*y=7373.0, 总和=24660.0 [平衡解] 2. x=220, y=320.0, a*x=12980.0, b*y=11680.0, 总和=24660.0 [平衡解] 3. x=1, y=674.0, a*x=59.0, b*y=24601.0, 总和=24660.0 [原始解] 4. x=74, y=556.0, a*x=4366.0, b*y=20294.0, 总和=24660.0 [原始解] 5. x=147, y=438.0, a*x=8673.0, b*y=15987.0, 总和=24660.0 [原始解] 12. 组合: a=59, b=41.5 (5 个有效解) 1. x=259, y=226.0, a*x=15281.0, b*y=9379.0, 总和=24660.0 [平衡解] 2. x=176, y=344.0, a*x=10384.0, b*y=14276.0, 总和=24660.0 [平衡解] 3. x=10, y=580.0, a*x=590.0, b*y=24070.0, 总和=24660.0 [原始解] 4. x=93, y=462.0, a*x=5487.0, b*y=19173.0, 总和=24660.0 [原始解] 5. x=342, y=108.0, a*x=20178.0, b*y=4482.0, 总和=24660.0 [原始解] 13. 组合: a=59, b=68.5 (3 个有效解) 1. x=137, y=242.0, a*x=8083.0, b*y=16577.0, 总和=24660.0 [平衡解] 2. x=274, y=124.0, a*x=16166.0, b*y=8494.0, 总和=24660.0 [平衡解] 3. x=411, y=6.0, a*x=24249.0, b*y=411.0, 总和=24660.0 [原始解] 14. 组合: a=59, b=74 (5 个有效解) 1. x=206, y=169, a*x=12154.0, b*y=12506.0, 总和=24660.0 [平衡解] 2. x=132, y=228, a*x=7788.0, b*y=16872.0, 总和=24660.0 [平衡解] 3. x=58, y=287, a*x=3422.0, b*y=21238.0, 总和=24660.0 [原始解] 4. x=280, y=110, a*x=16520.0, b*y=8140.0, 总和=24660.0 [原始解] 5. x=354, y=51, a*x=20886.0, b*y=3774.0, 总和=24660.0 [原始解] 15. 组合: a=59, b=91.5 (2 个有效解) 1. x=114, y=196.0, a*x=6726.0, b*y=17934.0, 总和=24660.0 [平衡解] 2. x=297, y=78.0, a*x=17523.0, b*y=7137.0, 总和=24660.0 [平衡解] 16. 组合: a=68.5, b=36.5 (4 个有效解) 1. x=214, y=274.0, a*x=14659.0, b*y=10001.0, 总和=24660.0 [平衡解] 2. x=287, y=137.0, a*x=19659.5, b*y=5000.5, 总和=24660.0 [平衡解] 3. x=68, y=548.0, a*x=4658.0, b*y=20002.0, 总和=24660.0 [原始解] 4. x=141, y=411.0, a*x=9658.5, b*y=15001.5, 总和=24660.0 [原始解] 17. 组合: a=68.5, b=41.5 (4 个有效解) 1. x=194, y=274.0, a*x=13289.0, b*y=11371.0, 总和=24660.0 [平衡解] 2. x=277, y=137.0, a*x=18974.5, b*y=5685.5, 总和=24660.0 [平衡解] 3. x=28, y=548.0, a*x=1918.0, b*y=22742.0, 总和=24660.0 [原始解] 4. x=111, y=411.0, a*x=7603.5, b*y=17056.5, 总和=24660.0 [原始解] 18. 组合: a=68.5, b=59 (3 个有效解) 1. x=242, y=137.0, a*x=16577.0, b*y=8083.0, 总和=24660.0 [平衡解] 2. x=124, y=274.0, a*x=8494.0, b*y=16166.0, 总和=24660.0 [平衡解] 3. x=6, y=411.0, a*x=411.0, b*y=24249.0, 总和=24660.0 [原始解] 19. 组合: a=68.5, b=74 (2 个有效解) 1. x=212, y=137.0, a*x=14522.0, b*y=10138.0, 总和=24660.0 [平衡解] 2. x=64, y=274.0, a*x=4384.0, b*y=20276.0, 总和=24660.0 [平衡解] 20. 组合: a=68.5, b=91.5 (1 个有效解) 1. x=177, y=137.0, a*x=12124.5, b*y=12535.5, 总和=24660.0 [平衡解] 21. 组合: a=74, b=36.5 (4 个有效解) 1. x=205, y=260.0, a*x=15170.0, b*y=9490.0, 总和=24660.0 [平衡解] 2. x=278, y=112.0, a*x=20572.0, b*y=4088.0, 总和=24660.0 [平衡解] 3. x=59, y=556.0, a*x=4366.0, b*y=20294.0, 总和=24660.0 [原始解] 4. x=132, y=408.0, a*x=9768.0, b*y=14892.0, 总和=24660.0 [原始解] 22. 组合: a=74, b=41.5 (4 个有效解) 1. x=248, y=152.0, a*x=18352.0, b*y=6308.0, 总和=24660.0 [平衡解] 2. x=165, y=300.0, a*x=12210.0, b*y=12450.0, 总和=24660.0 [平衡解] 3. x=82, y=448.0, a*x=6068.0, b*y=18592.0, 总和=24660.0 [原始解] 4. x=331, y=4.0, a*x=24494.0, b*y=166.0, 总和=24660.0 [原始解] 23. 组合: a=74, b=59 (5 个有效解) 1. x=169, y=206, a*x=12506.0, b*y=12154.0, 总和=24660.0 [平衡解] 2. x=228, y=132, a*x=16872.0, b*y=7788.0, 总和=24660.0 [平衡解] 3. x=51, y=354, a*x=3774.0, b*y=20886.0, 总和=24660.0 [原始解] 4. x=110, y=280, a*x=8140.0, b*y=16520.0, 总和=24660.0 [原始解] 5. x=287, y=58, a*x=21238.0, b*y=3422.0, 总和=24660.0 [原始解] 24. 组合: a=74, b=68.5 (2 个有效解) 1. x=137, y=212.0, a*x=10138.0, b*y=14522.0, 总和=24660.0 [平衡解] 2. x=274, y=64.0, a*x=20276.0, b*y=4384.0, 总和=24660.0 [平衡解] 25. 组合: a=74, b=91.5 (2 个有效解) 1. x=81, y=204.0, a*x=5994.0, b*y=18666.0, 总和=24660.0 [平衡解] 2. x=264, y=56.0, a*x=19536.0, b*y=5124.0, 总和=24660.0 [平衡解] 26. 组合: a=91.5, b=36.5 (4 个有效解) 1. x=163, y=267.0, a*x=14914.5, b*y=9745.5, 总和=24660.0 [平衡解] 2. x=236, y=84.0, a*x=21594.0, b*y=3066.0, 总和=24660.0 [平衡解] 3. x=17, y=633.0, a*x=1555.5, b*y=23104.5, 总和=24660.0 [原始解] 4. x=90, y=450.0, a*x=8235.0, b*y=16425.0, 总和=24660.0 [原始解] 27. 组合: a=91.5, b=41.5 (3 个有效解) 1. x=211, y=129.0, a*x=19306.5, b*y=5353.5, 总和=24660.0 [平衡解] 2. x=128, y=312.0, a*x=11712.0, b*y=12948.0, 总和=24660.0 [平衡解] 3. x=45, y=495.0, a*x=4117.5, b*y=20542.5, 总和=24660.0 [原始解] 28. 组合: a=91.5, b=59 (2 个有效解) 1. x=196, y=114.0, a*x=17934.0, b*y=6726.0, 总和=24660.0 [平衡解] 2. x=78, y=297.0, a*x=7137.0, b*y=17523.0, 总和=24660.0 [平衡解] 29. 组合: a=91.5, b=68.5 (1 个有效解) 1. x=137, y=177.0, a*x=12535.5, b*y=12124.5, 总和=24660.0 [平衡解] 30. 组合: a=91.5, b=74 (2 个有效解) 1. x=204, y=81.0, a*x=18666.0, b*y=5994.0, 总和=24660.0 [平衡解] 2. x=56, y=264.0, a*x=5124.0, b*y=19536.0, 总和=24660.0 [平衡解] 使用基础系数列表,共找到有效解 总耗时: 0.01秒