結果

問題 No.75 回数の期待値の問題
ユーザー リチウムリチウム
提出日時 2014-11-23 23:38:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,813 ms / 5,000 ms
コード長 479 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 71,632 KB
実行使用メモリ 56,340 KB
最終ジャッジ日時 2023-08-30 22:25:30
合計ジャッジ時間 17,063 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 219 ms
55,664 KB
testcase_01 AC 232 ms
55,700 KB
testcase_02 AC 235 ms
55,548 KB
testcase_03 AC 285 ms
55,600 KB
testcase_04 AC 237 ms
55,872 KB
testcase_05 AC 230 ms
55,712 KB
testcase_06 AC 230 ms
55,920 KB
testcase_07 AC 291 ms
55,968 KB
testcase_08 AC 296 ms
55,748 KB
testcase_09 AC 304 ms
55,656 KB
testcase_10 AC 315 ms
55,672 KB
testcase_11 AC 329 ms
55,940 KB
testcase_12 AC 351 ms
55,704 KB
testcase_13 AC 362 ms
56,216 KB
testcase_14 AC 374 ms
55,928 KB
testcase_15 AC 435 ms
55,748 KB
testcase_16 AC 1,298 ms
55,572 KB
testcase_17 AC 2,204 ms
55,760 KB
testcase_18 AC 2,628 ms
55,688 KB
testcase_19 AC 2,813 ms
56,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	
	
  public static void main(String[] args) {
	  Scanner sc=new Scanner(System.in);
	  int k=sc.nextInt();
	  Random r=new Random();
	  int ans=0;
	  int i=0;
	  while(i<1000000){
		  int sum=0;
		  int t=0;
		  while(true){
		  int n=r.nextInt(6)+1;
		  t++;
		  sum+=n;
		  if(sum>k)sum=0;
		  else if(sum==k)break;
		  }
		  ans+=t;
		  i++;
	  }
	  System.out.println((double)ans/1000000);
	  	  
  }
}
  
0