結果
| 問題 |
No.58 イカサマなサイコロ
|
| ユーザー |
kuuso1
|
| 提出日時 | 2014-11-05 00:24:54 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 5,000 ms |
| コード長 | 1,929 bytes |
| コンパイル時間 | 6,382 ms |
| コンパイル使用メモリ | 107,392 KB |
| 実行使用メモリ | 19,072 KB |
| 最終ジャッジ日時 | 2024-12-30 17:41:14 |
| 合計ジャッジ時間 | 2,254 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
double[][] P=new double[2][];
P[0]=new double[121];
P[0][60]=1.0;
Dictionary<int,int> dk=new Dictionary<int,int>();
for(int i=1;i<=6;i++){
for(int j=4;j<=6;j++){
int diff=j-i;
if(!dk.ContainsKey(diff))dk.Add(diff,0);
dk[diff]++;
dk[diff]++;
}
}
Dictionary<int,int> dn=new Dictionary<int,int>();
for(int i=1;i<=6;i++){
for(int j=1;j<=6;j++){
int diff=j-i;
if(!dn.ContainsKey(diff))dn.Add(diff,0);
dn[diff]++;
}
}
int now=0;
int next=0;
for(int i=0;i<N;i++){
now=i%2;
next=1-now;
P[next]=new double[121];
if(i<K){
for(int j=0;j<121;j++){
if(P[now][j]!=0){
foreach(int k in dk.Keys){
P[next][j+k]+=P[now][j]/36.0*dk[k];
}
}
}
}else{
for(int j=0;j<121;j++){
if(P[now][j]!=0){
foreach(int k in dn.Keys){
P[next][j+k]+=P[now][j]/36.0*dn[k];
}
}
}
}
}
double ans=0;
for(int j=60+1;j<121;j++){
ans+=P[next][j];
}
Console.WriteLine(ans);
}
int N;
int K;
public Sol(){
N=ri();
K=ri();
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(){return Console.ReadLine().Split(' ');}
static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
kuuso1