2012年4月30日 星期一

Gran Turismo 5

內容 :

最近,

籌錢買了一片 Gran Turismo 5 回家做賽車夢,

又另外買了 G27 方向盤,

但在賽車場上的表現始終不如人意。

"車,不是這麼開的。"

說完爸爸接過了方向盤,

將記錄一次又一次的刷新。

給你每一圈的時間紀錄,

請算出 Best Lap 與平均時間。

我一定要成為車神! 

輸入說明 :

第一行有一個數字 N (0 < N ≤ 10)

代表接下來有 N 組測試資料

每組測試資料第一行有一個數字 M (0 < M ≤ 100)

接著有 M 行資料

每行兩個數字 A, B (0 ≤ A, B ≤ 60)

代表該圈所花費時間為 A 分 B 秒 

輸出說明 :

Track X:

Best Lap: X minute(s) X second(s).

Average: X minute(s) X second(s). 

Average 為整數,小數部份無條件捨去

詳請參考範例測資 

範例輸入 :

3
4
1 54
2 02
1 58
1 50
3
1 23
1 42
1 37
5
3 00
2 56
3 04
2 50
3 01

範例輸出 :

Track 1:
Best Lap: 1 minute(s) 50 second(s).
Average: 1 minute(s) 56 second(s).

Track 2:
Best Lap: 1 minute(s) 23 second(s).
Average: 1 minute(s) 34 second(s).

Track 3:
Best Lap: 2 minute(s) 50 second(s).
Average: 2 minute(s) 58 second(s).

2 則留言:

  1. Private Sub Form_Load()
    Me.Hide
    Dim ans, c As Double
    Open App.Path & "\in.txt" For Input As #1
    Open App.Path & "\out.txt" For Output As #2
    Input #1, n
    For i = 1 To n
    ans = 0
    Min = 10000000000#
    Input #1, t
    For j = 1 To t
    Input #1, m, s
    c = m * 60 + s
    If c < Min Then Min = c
    ans = ans + (m * 60) + s
    Next
    m1 = Min \ 60
    s1 = Min Mod 60
    t1 = ans \ t
    m = t1 \ 60
    s = t1 Mod 60
    Print #2, "Track " & i & ":"
    Print #2, "Best Lap:" & m1 & " minute(s) " & s1 & " second(s)."
    Print #2, "Average:"; m & " minute(s) " & s & " second(s)."
    Print #2,
    Print #2,
    Next
    Close
    Close
    End
    End Sub

    回覆刪除
  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
    Input #1, t
    For q = 1 To Val(t)
    alls = 0
    best = 999
    Input #1, r
    ReDim all(Val(r))
    For i = 1 To Val(r)
    Input #1, m, s
    all(i) = Val(m) * 60 + Val(s)
    alls = all(i) + alls
    Next i
    ans = (alls / Val(r)) \ 60
    ansr = (alls / Val(r)) Mod 60
    For i = 1 To Val(r)
    For j = 1 To Val(r)
    If i <> j Then
    If all(i) < all(j) And all(i) < best Then best = all(i)
    End If
    Next j
    Next i
    rbest = best \ 60
    rbestr = best Mod 60
    Print #2, "Track" & q & ":"
    Print #2, "Best Lap: " & rbest & " minute(s) " & rbestr & " second(s)."
    Print #2, "Average: " & ans & " minute(s) " & ansr & " second(s)."
    Next q
    Close #2
    Close #1
    End
    End Sub

    回覆刪除