Dim num, ans As Integer Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, num num = num / 2 ans = ans + (num * (num - 1)) Do num = num / 2 ans = ans + num Loop Until num = 1 Print #2, ans + 1
Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, n n = n / 2 ans = n * (n - 1) Do n = n / 2 ans = ans + n Loop Until n = 4 ans = ans + 4 Print #2, ans Close #2 Close #1 End End Sub
Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, x x = x / 2: a = a + x * (x - 1) Do Until x = 1 x = x / 2: a = a + x Loop Print #2, a + 1 Close Close End End Sub
Private Sub Form_Load() Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Input #1, x a = Val(x) / 2 * (Val(x) / 2 - 1): b = Val(x) / 4: c = b Do c = c / 2 ans = ans + c Loop Until c = 1 ans = ans + 1 + a + b Print #2, ans Close #2 Close #1 End End Sub
Dim num, ans As Integer
回覆刪除Private Sub Form_Load()
Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, num
num = num / 2
ans = ans + (num * (num - 1))
Do
num = num / 2
ans = ans + num
Loop Until num = 1
Print #2, ans + 1
Close #2
Close #1
End
End Sub
作者已經移除這則留言。
回覆刪除Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, n
n = n / 2
ans = n * (n - 1)
Do
n = n / 2
ans = ans + n
Loop Until n = 4
ans = ans + 4
Print #2, ans
Close #2
Close #1
End
End Sub
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x
x = x / 2: a = a + x * (x - 1)
Do Until x = 1
x = x / 2: a = a + x
Loop
Print #2, a + 1
Close
Close
End
End Sub
Private Sub Form_Load()
回覆刪除Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Input #1, x
a = Val(x) / 2 * (Val(x) / 2 - 1): b = Val(x) / 4: c = b
Do
c = c / 2
ans = ans + c
Loop Until c = 1
ans = ans + 1 + a + b
Print #2, ans
Close #2
Close #1
End
End Sub