Private Sub Form_Load() Me.Hide Open App.Path & "\in.txt" For Input As #1 Open App.Path & "\out.txt" For Output As #2 Do While Not EOF(1) Input #1, N, M
If M <= 2 Then
If N = 1 Or M = 1 Then ans = 1 Else If N > 1 Then ans = N - 1 End If Print #2, ans
Else
If N <= M Then Print #2, 1 Else Print #2, (N \ M) + 1 End If
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, m
Dim Ti, nn
nn = n - m: Ti = Ti + 1
Do While nn >= m
nn = nn - (m - 1): Ti = Ti + 1
Loop
If nn > 0 Then Ti = Ti + 1
Print #2, Ti
Close
Close
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, M
If N <= M Then
Print #2, 1
Else
Print #2, (N \ M) + 1
End If
Close #2
Close #1
End
End Sub
in.txt-----------------
5 4
5 5
1 3
2 3
3 3
4 3
5 3
6 3
7 3
8 3
1 101
36767 1
36767 2
36767 3
36767 100
out.txt-------------------
2
1
1
1
1
2
2
3
3
3
1
36768
18384
12256
368
你的
回覆刪除36767 1
36767 2
好像有錯.
1入1出怎麼接都是1吧?
2的話好像是 32766
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Do While Not EOF(1)
Input #1, N, M
If M <= 2 Then
If N = 1 Or M = 1 Then
ans = 1
Else
If N > 1 Then ans = N - 1
End If
Print #2, ans
Else
If N <= M Then
Print #2, 1
Else
Print #2, (N \ M) + 1
End If
End If
Loop
Close #2
Close #1
End
End Sub
in.txt-----------------
5 4
5 5
1 3
2 3
3 3
4 3
5 3
6 3
7 3
8 3
1 101
36767 1
36767 2
36767 3
36767 100
out.txt-------------------
2
1
1
1
1
2
2
3
3
3
1
1
36766
12256
368