結果
問題 |
No.58 イカサマなサイコロ
|
ユーザー |
|
提出日時 | 2016-02-27 23:24:16 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 1,047 ms / 5,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 12,535 ms |
コンパイル使用メモリ | 240,032 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-10 23:06:41 |
合計ジャッジ時間 | 17,520 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
package main import ( "bufio" "fmt" "math/rand" "os" "strconv" "time" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) n, k := nextInt(), nextInt() r := rand.New(rand.NewSource(time.Now().UnixNano())) yW, tW := 0, 0 for i := 0; i < 4000000; i++ { y, t := 0, 0 for j := 0; j < n; j++ { y += r.Intn(6) + 1 } for j := 0; j < n-k; j++ { t += r.Intn(6) + 1 } for j := 0; j < k; j++ { t += r.Intn(3) + 4 } if y > t { yW++ } else if t > y { tW++ } } fmt.Println(float64(tW) / 4000000) } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }