結果

問題 No.75 回数の期待値の問題
ユーザー リチウムリチウム
提出日時 2014-11-23 23:26:56
言語 Java19
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 482 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 72,044 KB
実行使用メモリ 56,596 KB
最終ジャッジ日時 2023-08-30 22:22:10
合計ジャッジ時間 27,798 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 303 ms
56,092 KB
testcase_01 AC 329 ms
55,772 KB
testcase_02 AC 338 ms
56,248 KB
testcase_03 AC 437 ms
55,960 KB
testcase_04 AC 333 ms
56,292 KB
testcase_05 AC 320 ms
56,220 KB
testcase_06 AC 320 ms
55,844 KB
testcase_07 AC 441 ms
55,732 KB
testcase_08 AC 454 ms
55,868 KB
testcase_09 AC 468 ms
56,596 KB
testcase_10 AC 495 ms
56,192 KB
testcase_11 AC 514 ms
55,764 KB
testcase_12 AC 569 ms
55,576 KB
testcase_13 AC 578 ms
56,024 KB
testcase_14 AC 609 ms
55,828 KB
testcase_15 AC 739 ms
54,144 KB
testcase_16 AC 2,454 ms
55,956 KB
testcase_17 AC 4,242 ms
55,948 KB
testcase_18 TLE -
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

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<2000000){
		  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/2000000);
	  	  
  }
}
  
 
0