Submission #6438328


Source Code Expand

#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

double dp[201][101][101];

int main(void){
    int N;
    ll D;
    cin >> N >> D;

    int p[3] = {2, 3, 5};
    int num[3] = {0};
    for(int i = 0; i < 3; i++){
        while(D % p[i] == 0){
            D /= p[i];
            num[i]++;
        }
    }

    if(D > 1){
        cout << 0 << '\n';
        return 0;
    }

    dp[0][0][0] = 1.0;
    for(int i = 1; i <= N; i++){
        for(int j = 2*i; j >= 0; j--){
            for(int k = i; k >= 0; k--){
                for(int l = i; l >= 0; l--){
                    dp[j][k][l] = dp[j][k][l] / 6.0;
                    if(j>=1) dp[j][k][l] += dp[j-1][k][l] / 6.0;
                    if(k>=1) dp[j][k][l] += dp[j][k-1][l] / 6.0;
                    if(j>=2) dp[j][k][l] += dp[j-2][k][l] / 6.0;
                    if(l>=1) dp[j][k][l] += dp[j][k][l-1] / 6.0;
                    if(j>=1 and k>=1) dp[j][k][l] += dp[j-1][k-1][l] / 6.0;
                }
            }
        }
    }

    double res = 0;
    for(int i = num[0]; i <= 2*N; i++){
        for(int j = num[1]; j <= N; j++){
            for(int k = num[2]; k <= N; k++){
                res += dp[i][j][k];
            }
        }
    }

    cout << fixed << setprecision(9) << res << '\n';

    return 0;
}

Submission Info

Submission Time
Task D - サイコロ
User yna87
Language C++14 (GCC 5.4.1)
Score 4
Code Size 1453 Byte
Status AC
Exec Time 645 ms
Memory 14592 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 14 ms 5120 KB
01 AC 468 ms 14336 KB
02 AC 332 ms 12160 KB
03 AC 20 ms 5120 KB
04 AC 18 ms 5120 KB
05 AC 645 ms 14592 KB
06 AC 447 ms 14336 KB
07 AC 368 ms 14208 KB
08 AC 3 ms 2688 KB
09 AC 315 ms 12160 KB
10 AC 1 ms 256 KB
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB