結果
問題 | No.58 イカサマなサイコロ |
ユーザー |
![]() |
提出日時 | 2018-12-06 00:44:36 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 422 ms / 5,000 ms |
コード長 | 1,421 bytes |
コンパイル時間 | 3,662 ms |
コンパイル使用メモリ | 111,636 KB |
実行使用メモリ | 26,740 KB |
最終ジャッジ日時 | 2024-09-13 03:31:44 |
合計ジャッジ時間 | 4,252 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;using System.Collections.Generic;using System.Linq;using static System.Console;class Program{static void Main(){var N = int.Parse(ReadLine());var K = int.Parse(ReadLine());Span<int> t = stackalloc int[] { 4, 4, 5, 5, 6, 6 };var s = 0.0;var r = new XorShift();var l = 1000000;for (int i = 0; i < l; i++){var ts = 0;var js = 0;for (int k = 0; k < N - K; k++) ts += r.Next(6) + 1;for (int k = 0; k < K; k++) ts += t[r.Next(6)];for (int k = 0; k < N; k++) js += r.Next(6) + 1;if (ts > js) s++;}WriteLine(s / l);}}class XorShift{uint x = 123456789;uint y = 362436069;uint z = 521288629;uint w = 88675123;public XorShift(){var t = (uint)Environment.TickCount;x ^= t;y ^= Shift(t, 17);z ^= Shift(t, 31);w ^= Shift(t, 18);}uint Shift(uint u, int n) => u << n | u >> 32 - n;public int Next(){var t = x ^ x << 11;x = y; y = z; z = w;t = w = w ^ w >> 19 ^ t ^ t >> 8;if (t > int.MaxValue) t = ~t;return (int)(t == int.MaxValue ? --t : t);}public int Next(int maxValue) => (int)(NextDouble() * maxValue);public double NextDouble() => (double)Next() / int.MaxValue;}