Submission #1303313


Source Code Expand

#include<iostream>
#include<vector>
#include<string>
#include<stdio.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+2;
double dp[MAX_N][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);
}
double solve(int n,int a,int b,int c){
	a=max(0,a),b=max(0,b),c=max(0,c);
	if(a==0 && b==0 && c==0)return dp[n][a][b][c]=1;
	if(n==0)return dp[n][a][b][c]=0;
	if(dp[n][a][b][c]!=0)return dp[n][a][b][c];
	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];
}
int main(){
	ll n,d;
	cin>>n>>d;
	if(di(di(di(d,5),3),2)!=1)cout<<0<<endl;
	else printf("%.9f\n",solve(n,divi(d,2),divi(d,3),divi(d,5))); 
}

Submission Info

Submission Time
Task D - サイコロ
User ryogo108
Language C++14 (GCC 5.4.1)
Score 0
Code Size 977 Byte
Status TLE
Exec Time 2103 ms
Memory 35328 KB

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
AC × 3
TLE × 10
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 TLE 2103 ms 22784 KB
01 TLE 2103 ms 24832 KB
02 TLE 2103 ms 26880 KB
03 TLE 2103 ms 26880 KB
04 TLE 2103 ms 29056 KB
05 TLE 2103 ms 29056 KB
06 TLE 2103 ms 31232 KB
07 TLE 2103 ms 35328 KB
08 TLE 2103 ms 33152 KB
09 TLE 2103 ms 30976 KB
10 AC 1 ms 256 KB
90 AC 2 ms 4352 KB
91 AC 3 ms 6400 KB