Submission #6360982


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

double dp[2][70][70][70];

int a,b,c;

bool ddiv(ll d){
    while(d%2==0){
        d/=2;a++;
    }
    while(d%3==0){
        d/=3;b++;
    }
    while(d%5==0){
        d/=5;c++;
    }
    if(d!=1)return false;
    return true;
}

int main(){
    int n;cin>>n;
    ll d;cin>>d;
    if(!ddiv(d)){
        cout<<0<<endl;
        exit(0);
    }
    dp[0][0][0][0]=(double)1;
    int cur=0;
    int next=1;
    double ans=0;
    
    rep(i,n){
        rep(j,70) rep(k,70) rep(l,70) dp[next][j][k][l]=0;
        rep(j,70) rep(k,70) rep(l,70){
        dp[next][j][k][l]+=dp[cur][j][k][l]/6.0;
        dp[next][min(69,j+1)][k][l]+=dp[cur][j][k][l]/6.0;
        dp[next][j][min(69,k+1)][l]+=dp[cur][j][k][l]/6.0;
        dp[next][min(69,j+2)][k][l]+=dp[cur][j][k][l]/6.0;
        dp[next][j][k][min(69,l+1)]+=dp[cur][j][k][l]/6.0;
        dp[next][min(69,j+1)][min(69,k+1)][l]+=dp[cur][j][k][l]/6.0;
        }

        swap(cur,next);
        
    }
    rep(i,a,70) rep(j,b,70) rep(k,c,70){
        ans+=dp[cur][i][j][k];
    }
    cout<<fixed<<setprecision(14)<<ans<<endl;
}

Submission Info

Submission Time
Task D - サイコロ
User meimon
Language C++14 (GCC 5.4.1)
Score 4
Code Size 1679 Byte
Status AC
Exec Time 595 ms
Memory 5632 KB

Judge Result

Set Name All
Score / Max Score 4 / 4
Status
AC × 13
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 188 ms 5632 KB
01 AC 537 ms 5632 KB
02 AC 482 ms 5632 KB
03 AC 212 ms 5632 KB
04 AC 206 ms 5632 KB
05 AC 595 ms 5632 KB
06 AC 529 ms 5632 KB
07 AC 497 ms 5632 KB
08 AC 101 ms 5632 KB
09 AC 474 ms 5632 KB
10 AC 1 ms 256 KB
90 AC 15 ms 5632 KB
91 AC 21 ms 5632 KB