結果

問題 No.58 イカサマなサイコロ
ユーザー yukirinyukirin
提出日時 2016-02-27 23:23:08
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 11,210 ms
コンパイル使用メモリ 229,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 06:25:37
合計ジャッジ時間 26,108 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math/rand"
	"os"
	"strconv"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

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 < 10000000; 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) / 1000000)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}
0