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 Until EOF(1) Input #1, x ans = 0 For i = 1 To x y = i Do If y Mod 5 = 0 Then ans = ans + 1 y = y \ 5 Else Exit Do End If Loop Next Print #2, ans Loop 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 Do Until EOF(1) Input #1, n ans = 0 For i = 1 To n If i Mod 5 = 0 Then ans = ans + 1 End If Next i Print #2, ans Loop 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 Dim n As Long Do Until EOF(1) Input #1, n m = 1 Sum = 0 For i = 1 To n m = m * i If m Mod 10 = 0 Then m = m \ 10 Sum = Sum + 1 End If Next i Print #2, Sum Loop 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
Do Until EOF(1)
Input #1, x
ans = 0
For i = 1 To x
y = i
Do
If y Mod 5 = 0 Then
ans = ans + 1
y = y \ 5
Else
Exit Do
End If
Loop
Next
Print #2, ans
Loop
Close
Close
End
End Sub
小冰好,
回覆刪除這題正確。
改進點:既然都是關係到5,那麼外圈就用step 5可以更簡單。
內圈
do whil y mod 5=0
ans=ans +1
y=y\5
loop
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 Until EOF(1)
Input #1, n
ans = 0
For i = 1 To n
If i Mod 5 = 0 Then
ans = ans + 1
End If
Next i
Print #2, ans
Loop
Close #2
Close #1
End
End Sub
晟晟好,
回覆刪除這題並不正確哦。
出現0的地方,除了5,10,15,20,之外,下一個25,就有不同的狀況了。
另外,
這題還有一個副題是,算階「乘」中的第1個不是0的數字。
也就是本題是算幾個0,副題是算這幾個0之後,第1個不是0的數。
(當然,要算第2個也行哦)
Private Sub Form_Load()
回覆刪除Me.Hide
Open App.Path & "\in.txt" For Input As #1
Open App.Path & "\out.txt" For Output As #2
Dim n As Long
Do Until EOF(1)
Input #1, n
m = 1
Sum = 0
For i = 1 To n
m = m * i
If m Mod 10 = 0 Then
m = m \ 10
Sum = Sum + 1
End If
Next i
Print #2, Sum
Loop
Close #2
Close #1
End
End Sub