結果

問題 No.75 回数の期待値の問題
ユーザー NoNo
提出日時 2015-06-23 00:19:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,081 ms / 5,000 ms
コード長 1,266 bytes
コンパイル時間 2,516 ms
コンパイル使用メモリ 104,876 KB
実行使用メモリ 77,504 KB
最終ジャッジ日時 2023-09-21 23:52:58
合計ジャッジ時間 22,951 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 936 ms
74,412 KB
testcase_01 AC 1,046 ms
77,504 KB
testcase_02 AC 1,039 ms
75,456 KB
testcase_03 AC 957 ms
55,876 KB
testcase_04 AC 1,081 ms
76,380 KB
testcase_05 AC 1,048 ms
74,448 KB
testcase_06 AC 1,009 ms
76,304 KB
testcase_07 AC 953 ms
53,904 KB
testcase_08 AC 948 ms
54,036 KB
testcase_09 AC 943 ms
53,940 KB
testcase_10 AC 932 ms
52,988 KB
testcase_11 AC 914 ms
54,072 KB
testcase_12 AC 896 ms
39,020 KB
testcase_13 AC 888 ms
38,904 KB
testcase_14 AC 881 ms
40,420 KB
testcase_15 AC 854 ms
37,392 KB
testcase_16 AC 775 ms
26,548 KB
testcase_17 AC 764 ms
24,784 KB
testcase_18 AC 759 ms
24,720 KB
testcase_19 AC 760 ms
24,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace foryuki
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Random r = new Random();
            int cnt = 0;
            int m = 0;
            var l = new List<int>();

            for (int i = 0; i < 30000000; i++)
            {
                cnt++;
                m += r.Next(1, 7);

                if (m > n)
                {
                    m = 0;
                }
                else if (m == n)
                {
                    l.Add(cnt);
                    m = 0;
                    cnt = 0;
                }
            }
            Console.WriteLine(l.Average());
        }

        //-------------------------------------------------------------

        static int[] ConvertStringArrayToIntArray(string[] array)
        {
            return Array.ConvertAll(array, str => int.Parse(str));
        }

        static List<int> ConvertStringArrayToIntList(string[] str)
        {
            var list = new List<int>();
            foreach (var c in str) list.Add(int.Parse(c));
            return list;
        }
    }
}
0