Submission #1303552
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);
}
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;
rep(i,n){
rep(j,2*i+1)rep(k,i+1)rep(l,i+1)if(dp[i][j][k][l]){
FOR(m,1,7)dp[i+1][j+divi(m,2)][k+divi(m,3)][l+divi(m,5)]=dp[i][j][k][l];
}
}
}
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);
solve(n);
FOR(i,i_m,201)FOR(j,j_m,101)FOR(k,k_m,101)ans+=dp[n][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 |
1240 Byte |
Status |
WA |
Exec Time |
723 ms |
Memory |
844160 KB |
Judge Result
Set Name |
All |
Score / Max Score |
0 / 4 |
Status |
|
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 |
WA |
37 ms |
151808 KB |
01 |
MLE |
386 ms |
484864 KB |
02 |
MLE |
372 ms |
525952 KB |
03 |
WA |
46 ms |
180480 KB |
04 |
WA |
43 ms |
172288 KB |
05 |
MLE |
521 ms |
662656 KB |
06 |
MLE |
417 ms |
643196 KB |
07 |
MLE |
304 ms |
616320 KB |
08 |
AC |
14 ms |
57600 KB |
09 |
MLE |
267 ms |
593152 KB |
10 |
MLE |
723 ms |
844160 KB |
90 |
WA |
4 ms |
4352 KB |
91 |
WA |
4 ms |
6400 KB |