|
本帖最后由 ysr 于 2021-2-14 07:43 编辑
当x+y=10001有4组解: /解/8181/1820/8381其中(x + z) / 2=8281其方根为:91
/解/6165/3836/7261其中(x + z) / 2=6713其方根为:81.9328993750374
/解/4745/5256/7081其中(x + z) / 2=5913其方根为:76.8960337078578
/解/1197/8804/8885其中(x + z) / 2=5041其方根为:71
若方根不是整数的话,以前的勾股数公式能解出来吗?如何解的?
Private Sub Command1_Click()
Dim a, b, x, y, z, m
m = Text2
b1 = m / 2
b = 0
s1 = 0
Do While b < Val(b1) + 2
a = b
b = b + 1
Print b
Do While a < Val(m)
a = a + 1
x = a - b
y = 2 * (a * b) ^ (1 / 2)
z = Sqr(x ^ 2 + y ^ 2)
If InStr(z, ".") = 0 And x + y = Val(m) Then
m1 = (x + z) / 2
m2 = Sqr(m1)
s = s & "/解/" & x & "/" & y & "/" & z & "其中(x + z) / 2=" & m1 & "其方根为:" & m2 & vbCrLf
s1 = s1 + 1
Else
s = s
End If
Loop
Loop
Text1 = Text1 & "当x+y=" & m & "有" & s1 & "组解: " & s
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Form1.Cls
End Sub
|
|