Submission #2106069
Source Code Expand
#include "bits/stdc++.h"
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 102;
double dp[MAX_N][MAX_N][MAX_N][MAX_N];
int main(){
int N; ll D; cin >> N >> D;
int cnt2=0,cnt3=0,cnt5=0;
while(D%2LL==0) D/=2LL,cnt2++;
while(D%3LL==0) D/=3LL,cnt3++;
while(D%3LL==0) D/=5LL,cnt5++;
if(D!=1LL){
cout << "0.0" << endl;
return 0;
}
dp[0][0][0][0] = 1.0;
rep(i,N) rep(j,cnt2+1) rep(k,cnt3+1) rep(l,cnt5+1){
dp[i+1][j][k][l] += dp[i][j][k][l]/6;
dp[i+1][min(j+1,cnt2)][k][l] += dp[i][j][k][l]/6;
dp[i+1][j][min(k+1,cnt3)][l] += dp[i][j][k][l]/6;
dp[i+1][min(j+2,cnt2)][k][l] += dp[i][j][k][l]/6;
dp[i+1][j][k][min(l+1,cnt5)] += dp[i][j][k][l]/6;
dp[i+1][min(j+1,cnt2)][min(k+1,cnt3)][l] += dp[i][j][k][l]/6;
}
printf("%.10lf",dp[N][cnt2][cnt3][cnt5]);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - サイコロ |
User |
kurarrr |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1303 Byte |
Status |
WA |
Exec Time |
65 ms |
Memory |
325888 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 |
AC |
1 ms |
256 KB |
01 |
WA |
1 ms |
256 KB |
02 |
WA |
1 ms |
256 KB |
03 |
WA |
1 ms |
256 KB |
04 |
WA |
1 ms |
256 KB |
05 |
WA |
1 ms |
256 KB |
06 |
WA |
1 ms |
256 KB |
07 |
MLE |
65 ms |
325888 KB |
08 |
AC |
1 ms |
256 KB |
09 |
WA |
1 ms |
256 KB |
10 |
AC |
1 ms |
256 KB |
90 |
AC |
2 ms |
4352 KB |
91 |
AC |
2 ms |
6400 KB |