2012年11月20日 星期二

足球比賽場次

說明:足球比賽採初、複賽,初賽時將參賽隊伍分成2組(N/2)採單循環(必須與同組各隊比1次)取前一半隊伍進入複賽(N/4),每複賽為單淘汰(勝隊晉級),比賽將頒發前3名。計算所需對賽之場次數目,如N = 16 ,初賽分2組各8對單循環淘汰賽,每組28場計56場,得8隊晉級複賽。8對單淘汰4場4隊晉級,4對單淘汰2場得勝2隊晉級冠軍賽1場,輸的2隊爭季軍賽1場。 合計 56 +4 +2 +1 +1 = 64 場

5 則留言:

  1. 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

    回覆刪除
  2. 作者已經移除這則留言。

    回覆刪除
  3. 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

    回覆刪除
  4. 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

    回覆刪除
  5. 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

    回覆刪除