Submission #1303558


Source Code Expand

#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<string.h>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=1e2+10;
double dp[2][2*MAX_N][MAX_N][MAX_N];

ll max(ll a,ll b){
	if(a>b)return a;
	else return b;
}

ll divi(ll n,ll d){
	if(n%d!=0)return 0;
	else return divi(n/d,d)+1;
}
ll di(ll n,ll d){
	if(n%d!=0)return n;
	else return di(n/d,d);
}
/*void solve(int n){
	*if(a<0 || b<0 || c<0)return 0;
	if(dp[n][a][b][c]!=0)return dp[n][a][b][c];
	if(n==0 && a==0 && b==0 && c==0)return dp[n][a][b][c]=1;
	if(n==0)return dp[n][a][b][c]=0;
	FOR(i,1,7){
		dp[n][a][b][c]+=solve(n-1,a-divi(i,2),b-divi(i,3),c-divi(i,5))/6.0;
	}
	return dp[n][a][b][c];
	dp[0][0][0][0]=1;
	int cur=0;
	rep(i,n){
		int next=cur^1;
		memset(dp[next],0,sizeof(dp[next]));
		rep(j,2*i+1)rep(k,i+1)rep(l,i+1)if(dp[i][j][k][l]){
			FOR(m,1,7)dp[next][j+divi(m,2)][k+divi(m,3)][l+divi(m,5)]=dp[cur][j][k][l];
		}
		cur=next
	}
}*/
int main(){
	ll n,d;
	cin>>n>>d;
	if(di(di(di(d,5),3),2)!=1)cout<<0<<endl;
	double ans=0;
	int i_m=divi(d,2),j_m=divi(d,3),k_m=divi(d,5);
	dp[0][0][0][0]=1;
	int cur=0;
	rep(i,n){
		int next=cur^1;
		memset(dp[next],0,sizeof(dp[next]));
		rep(j,2*i+1)rep(k,i+1)rep(l,i+1)if(dp[cur][j][k][l]){
			FOR(m,1,7)dp[next][j+divi(m,2)][k+divi(m,3)][l+divi(m,5)]+=dp[cur][j][k][l]/6.0;
		}
		cur=next;
	}
	FOR(i,i_m,201)FOR(j,j_m,101)FOR(k,k_m,101)ans+=dp[cur][i][j][k];
	printf("%.7f\n",ans);
}

Submission Info

Submission Time
Task D - サイコロ
User ryogo108
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1603 Byte
Status WA
Exec Time 699 ms
Memory 41984 KB

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
AC × 12
WA × 1
Set Name Test Cases
All 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 90, 91
Case Name Status Exec Time Memory
00 AC 89 ms 41856 KB
01 AC 431 ms 41856 KB
02 AC 341 ms 41984 KB
03 AC 102 ms 41856 KB
04 AC 97 ms 41856 KB
05 AC 519 ms 41856 KB
06 AC 408 ms 41856 KB
07 AC 364 ms 41856 KB
08 AC 49 ms 41856 KB
09 AC 329 ms 41856 KB
10 WA 699 ms 41856 KB
90 AC 14 ms 41856 KB
91 AC 16 ms 41856 KB