Dim d(1000000) Private Sub Form_Load() Me.Hide Open App.Path & "\out3.txt" For Output As #2 Open App.Path & "\in3.txt" For Input As #1
Input #1, n d(0) = 0 d(1) = 1 d(2) = 1 For i = 3 To n dd = p(d(i - 2), d(i - 3)) d(i) = p(d(i - 1), dd) Next i Print #2, d(n) Close #1 Close #2 End End Sub Function p(ByVal a1, ByVal b1) If Len(a1) < Len(b1) Then Call cz(a1, b1) If Len(a1) > Len(b1) Then Call cz(b1, a1) Lena1 = Len(a1) lenb1 = Len(b1) For i = Len(a1) To 1 Step -1 m1 = Mid(a1, i, 1) n1 = Mid(b1, i, 1) o1 = Val(m1) + Val(n1) X1 = o1 Mod 10 z1 = X1 + Y1 Y1 = o1 \ 10 c1 = z1 & c1 Next i If Y1 > 0 Then c1 = Y1 & c1 p = c1 End Function Sub cz(a4, b4) Do a4 = "0" & a4 If Len(a4) = Len(b4) Then Exit Do Loop End Sub
Open App.Path & "\in3.txt" For Input As #1 Open App.Path & "\out3.txt" For Output As #2 Input #1, N List1.AddItem 1 List1.AddItem 1 List1.AddItem 2 For i = 4 To N List1.List(i - 1) = Val(List1.List(i - 2)) + Val(List1.List(i - 3)) + Val(List1.List(i - 4)) If i = N Then ans = List1.List(i - 1) Next i
Dim d(1000000)
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\out3.txt" For Output As #2
Open App.Path & "\in3.txt" For Input As #1
Input #1, n
d(0) = 0
d(1) = 1
d(2) = 1
For i = 3 To n
dd = p(d(i - 2), d(i - 3))
d(i) = p(d(i - 1), dd)
Next i
Print #2, d(n)
Close #1
Close #2
End
End Sub
Function p(ByVal a1, ByVal b1)
If Len(a1) < Len(b1) Then Call cz(a1, b1)
If Len(a1) > Len(b1) Then Call cz(b1, a1)
Lena1 = Len(a1)
lenb1 = Len(b1)
For i = Len(a1) To 1 Step -1
m1 = Mid(a1, i, 1)
n1 = Mid(b1, i, 1)
o1 = Val(m1) + Val(n1)
X1 = o1 Mod 10
z1 = X1 + Y1
Y1 = o1 \ 10
c1 = z1 & c1
Next i
If Y1 > 0 Then c1 = Y1 & c1
p = c1
End Function
Sub cz(a4, b4)
Do
a4 = "0" & a4
If Len(a4) = Len(b4) Then Exit Do
Loop
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in3.txt" For Input As #1
Open App.Path & "\out3.txt" For Output As #2
Input #1, N
a = 1: b = 1: c = 2
For i = 1 To N - 3
tmp = a + b + c
a = b: b = c: c = tmp
Next
Print #2, c
Close #2
Close #1
End
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Dim N As Byte
Open App.Path & "\in3.txt" For Input As #1
Open App.Path & "\out3.txt" For Output As #2
Input #1, N
List1.AddItem 1
List1.AddItem 1
List1.AddItem 2
For i = 4 To N
List1.List(i - 1) = Val(List1.List(i - 2)) + Val(List1.List(i - 3)) + Val(List1.List(i - 4))
If i = N Then ans = List1.List(i - 1)
Next i
Print #2, ans
Close #2
Close #1
End
End Sub
緣尉 Arro 佑 各位好
回覆刪除你們的程式都對呦!^.<
不錯呦!
結果,是緣尉的大數加法錯了,連帶著,這個費氏也錯了。
回覆刪除可惜了。