結果
| 問題 | No.75 回数の期待値の問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-23 23:40:18 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 1,356 ms / 5,000 ms |
| コード長 | 480 bytes |
| 記録 | |
| コンパイル時間 | 1,993 ms |
| コンパイル使用メモリ | 76,660 KB |
| 実行使用メモリ | 54,716 KB |
| 最終ジャッジ日時 | 2025-01-02 20:38:24 |
| 合計ジャッジ時間 | 10,484 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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<500000){
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/500000);
}
}