結果
| 問題 |
No.58 イカサマなサイコロ
|
| ユーザー |
tenten
|
| 提出日時 | 2022-07-28 18:19:18 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 5,000 ms |
| コード長 | 1,983 bytes |
| コンパイル時間 | 2,173 ms |
| コンパイル使用メモリ | 78,532 KB |
| 実行使用メモリ | 51,064 KB |
| 最終ジャッジ日時 | 2024-07-18 08:56:56 |
| 合計ジャッジ時間 | 3,395 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
import java.io.*;
import java.util.*;
public class Main {
static HashSet<String> ans = new HashSet<>();
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
int n = sc.nextInt();
int k = sc.nextInt();
int[][] taro = new int[n + 1][n * 6 + 1];
int[][] jiro = new int[n + 1][n * 6 + 1];
taro[0][0] = 1;
jiro[0][0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = (i - 1) * 1; j <= (i - 1) * 6; j++) {
for (int a = 1; a <= 6; a++) {
jiro[i][j + a] += jiro[i - 1][j];
}
if (i <= k) {
for (int a = 4; a <= 6; a++) {
taro[i][j + a] += taro[i - 1][j] * 2;
}
} else {
for (int a = 1; a <= 6; a++) {
taro[i][j + a] += taro[i - 1][j];
}
}
}
}
double sum = 0;
double ans = 0;
for (int i = 0; i <= n * 6; i++) {
ans += sum * taro[n][i];
sum += jiro[n][i];
}
ans /= Math.pow(Math.pow(6, n), 2);
System.out.println(new java.math.BigDecimal(ans).toPlainString());
}
}
class Scanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
public Scanner() throws Exception {
}
public int nextInt() throws Exception {
return Integer.parseInt(next());
}
public long nextLong() throws Exception {
return Long.parseLong(next());
}
public double nextDouble() throws Exception {
return Double.parseDouble(next());
}
public String next() throws Exception {
while (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
}
tenten