- 注册时间
- 2008-4-24
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 2111
- 在线时间
- 小时
|
数论爱好者 发表于 2025-4-26 00:00
满足条件的三元组c≤100
[[1, 2, 4], [1, 2, 32], [3, 3, 3], [3, 3, 24], [3, 3, 81] ... - FindAllTriples := proc(N)
- local b, factors, divisors, pairs, d1, d2, a, k, m, c, triples;
- triples := [];
- # 遍历所有可能的b值(修正范围:b ≤ N,而非N^(1/3))
- for b from 1 to N do
- # 生成b^3的所有因数
- factors := ifactors(b^3)[2];
- divisors := generate_divisors(factors);
- pairs := generate_ordered_pairs(divisors, b^3); # 传入b^3的值用于验证
-
- # 处理每个因数对 (d1, d2)
- for pair in pairs do
- d1 := pair[1];
- d2 := pair[2];
- # 检查d1和d2的奇偶性相同
- if type(d1 + d2, even) then
- # 计算a和k
- a := (d2 - d1) / 2;
- k := (d2 + d1) / 2;
- # 检查a是否为整数且大于0
- if a > 0 and type(a, integer) then
- # 计算满足条件2的c值
- min_m := ceil((a*b)^(1/3));
- for m from min_m do
- c := m^3 / (a*b);
- if c > N then break end if;
- if c::posint then
- triples := [op(triples), [a, b, c]];
- end if;
- end do;
- end if;
- end if;
- end do;
- end do;
- return triples;
- end proc:
- # 辅助函数1:生成所有因数
- generate_divisors := proc(factors)
- local divisors, p, e, temp, i, j;
- divisors := [1];
- for f in factors do
- p := op(1, f);
- e := op(2, f);
- temp := [];
- for d in divisors do
- for j from 0 to e do
- temp := [op(temp), d * p^j];
- end do;
- end do;
- divisors := temp;
- end do;
- return divisors;
- end proc:
- # 辅助函数2:生成有序因数对,并验证d1*d2 = target
- generate_ordered_pairs := proc(divisors, target)
- local pairs, i, j, d1, d2;
- pairs := [];
- for i from 1 to nops(divisors) do
- for j from i to nops(divisors) do
- d1 := divisors[i];
- d2 := divisors[j];
- if d1 * d2 = target then
- pairs := [op(pairs), [d1, d2]];
- end if;
- end do;
- end do;
- return pairs;
- end proc:
- # 示例验证(N=100)
- result := FindAllTriples(100);
- print("所有符合条件的三元组:");
- print(result);
复制代码
运行结果:
[[1, 2, 4], [1, 2, 32], [3, 3, 3], [3, 3, 24], [3, 3, 81], [6, 4, 9], [6, 4, 72], [10, 5, 20], [21, 7, 63], [28, 8, 98], [8, 8, 1], [8, 8, 8], [8, 8, 27], [8, 8, 64], [120, 9, 25], [36, 9, 18], [45, 10, 60], [6, 12, 3], [6, 12, 24], [6, 12, 81], [24, 12, 6], [24, 12, 48], [48, 16, 18], [136, 17, 17], [27, 18, 12], [27, 18, 96], [171, 19, 57], [80, 20, 5], [80, 20, 40], [375, 24, 3], [375, 24, 24], [375, 24, 81], [120, 24, 75], [1089, 27, 33], [81, 27, 9], [81, 27, 72], [63, 28, 42], [378, 28, 7], [378, 28, 56], [15, 30, 60], [64, 32, 2], [64, 32, 16], [64, 32, 54], [88, 33, 99], [405, 36, 50], [162, 36, 1], [162, 36, 8], [162, 36, 27], [162, 36, 64], [960, 36, 50], [288, 36, 36], [270, 40, 20], [60, 40, 90], [360, 40, 15], [270, 45, 60], [48, 48, 6], [48, 48, 48], [192, 48, 12], [192, 48, 96], [125, 50, 20], [1485, 55, 55], [847, 56, 77], [28, 56, 14], [15, 60, 30], [63, 63, 63], [567, 63, 7], [567, 63, 56], [384, 64, 36], [1088, 68, 34], [216, 72, 3], [216, 72, 24], [216, 72, 81], [375, 75, 15], [640, 80, 10], [640, 80, 80], [3240, 81, 75], [972, 81, 2], [972, 81, 16], [972, 81, 54], [14, 84, 63], [3000, 96, 6], [3000, 96, 48], [343, 98, 28], [1875, 100, 18], [750, 100, 45]] |
|