結果

問題 No.75 回数の期待値の問題
ユーザー NoNo
提出日時 2015-06-23 00:16:22
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 1,064 ms / 5,000 ms
コード長 1,298 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 107,532 KB
実行使用メモリ 76,604 KB
最終ジャッジ日時 2023-09-21 23:51:53
合計ジャッジ時間 23,016 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 937 ms
75,456 KB
testcase_01 AC 1,041 ms
74,528 KB
testcase_02 AC 1,033 ms
76,476 KB
testcase_03 AC 956 ms
56,012 KB
testcase_04 AC 1,064 ms
74,388 KB
testcase_05 AC 1,046 ms
76,604 KB
testcase_06 AC 1,011 ms
74,504 KB
testcase_07 AC 951 ms
55,960 KB
testcase_08 AC 942 ms
56,184 KB
testcase_09 AC 944 ms
54,980 KB
testcase_10 AC 929 ms
51,896 KB
testcase_11 AC 917 ms
53,928 KB
testcase_12 AC 898 ms
39,408 KB
testcase_13 AC 892 ms
40,904 KB
testcase_14 AC 886 ms
38,340 KB
testcase_15 AC 858 ms
39,524 KB
testcase_16 AC 779 ms
28,556 KB
testcase_17 AC 766 ms
24,808 KB
testcase_18 AC 764 ms
24,652 KB
testcase_19 AC 763 ms
24,660 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());
            Console.ReadLine();
        }

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

        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