結果

問題 No.66 輝け☆全国たこやき杯
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-05-08 10:27:20
言語 Go
(1.22.1)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 1,383 bytes
コンパイル時間 10,536 ms
コンパイル使用メモリ 241,044 KB
実行使用メモリ 12,060 KB
最終ジャッジ日時 2024-04-18 10:47:42
合計ジャッジ時間 10,954 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 10 ms
6,940 KB
testcase_09 AC 29 ms
12,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

var DEBUG bool = false
func debugln(s string) { if DEBUG { fmt.Println(s) } }
func debug(s string, a ...interface{}) { if DEBUG { fmt.Printf(s, a...) } }

func mypow(a int, n int) int {
  var res = 1
  for ; n>0; n>>=1 {
    if n&1 == 1 { res *= a }
    a *= a
  }
  return res
}

func mypowf64(a int, n int) float64 { return float64(mypow(a, n)) }

func main() {
  var m int; fmt.Scanf("%d", &m)
  sz := mypow(2, m)
  s := make([]int, sz)
  for i := range s {
    fmt.Scanf("%d", &s[i])
  }
  vs:= make([][]float64, sz)
  for i := range vs {
    vs[i] = make([]float64, sz)
    for j := range vs[i] {
      vs[i][j] = mypowf64(s[i], 2) / (mypowf64(s[i], 2) + mypowf64(s[j], 2))
    }
  }
  prob := make([][]float64, m)
  for i := range prob { prob[i] = make([]float64, sz) }
  done := make([][]bool, sz)
  for i := range done { done[i] = make([]bool, sz) }
  for i := range prob {
    for j := range prob[i] {
      prob[i][j] = 0.
      start := j / mypow(2, i+1) * mypow(2, i+1)
      kosuu := mypow(2, i+1)
      for k :=start; k<start+kosuu; k++ {
        if(j == k) { continue }
        if(done[j][k]) { continue }
        a := 1.
        b := 1.
        if i > 0 {
          a = prob[i-1][j]
          b = prob[i-1][k]
        }
        prob[i][j] += a * vs[j][k] * b
        done[j][k] = true
      }
    }
  }
  fmt.Printf("%f\n", prob[m-1][0])
}
0