結果
| 問題 | No.75 回数の期待値の問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-23 23:38:49 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 2,588 ms / 5,000 ms |
| コード長 | 479 bytes |
| 記録 | |
| コンパイル時間 | 1,692 ms |
| コンパイル使用メモリ | 82,036 KB |
| 実行使用メモリ | 43,136 KB |
| 最終ジャッジ日時 | 2026-06-06 07:21:09 |
| 合計ジャッジ時間 | 14,499 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
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);
}
}