Submission #3015012


Source Code Expand

#include <iostream>
#include <iomanip>
#include <cstring>

using ll = long long;
using namespace std;
double dp[2][80][60][40];

int main() {
    int n;
    int l[3] = {2,3,5};
    int ld[3] = {};
    ll d;
    cin >> n >> d;
    for (int i = 0; i < 3; ++i) {
        while (d % l[i] == 0){
            d /= l[i];
            ld[i]++;
        }
    }
    if(d > 1){
        cout << setprecision(12) << 0.0 << "\n";
    }
    fill_n(&dp[0][0][0][0], 384000, 0.0);
    dp[0][0][0][0] = 1.0f;

    for (int i = 0; i <= n; ++i) {
        int a = i % 2;
        int b = 1^a;
        fill_n(&dp[b][0][0][0], 192000, 0);
        for (int j = 0; j < 80; ++j) {
            for (int k = 0; k < 60; ++k) {
                for (int m = 0; m < 40; ++m) {
                    if(dp[a][j][k][m] == 0.0) continue;
                    dp[b][j][k][m] += (dp[a][j][k][m]/6.0);
                    dp[b][j+1][k][m] += (dp[a][j][k][m]/6.0);
                    dp[b][j][k+1][m] += (dp[a][j][k][m]/6.0);
                    dp[b][j+2][k][m] += (dp[a][j][k][m]/6.0);
                    dp[b][j][k][m+1] += (dp[a][j][k][m]/6.0);
                    dp[b][j+1][k+1][m] += (dp[a][j][k][m]/6.0);
                }
            }
        }
    }
    double ans = 0.0;
    for (int i = ld[0]; i < 80; ++i) {
        for (int j = ld[1]; j < 60; ++j) {
            for (int k = ld[2]; k < 40; ++k) {
                ans += dp[n%2][i][j][k];
            }
        }
    }

    cout << setprecision(14) << ans << "\n";
    return 0;
}

Submission Info

Submission Time
Task D - サイコロ
User firiexp
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1559 Byte
Status RE
Exec Time 123 ms
Memory 3200 KB

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
AC × 6
RE × 7
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 18 ms 3200 KB
01 RE 122 ms 3200 KB
02 RE 122 ms 3200 KB
03 AC 22 ms 3200 KB
04 AC 21 ms 3200 KB
05 RE 122 ms 3200 KB
06 RE 122 ms 3200 KB
07 RE 123 ms 3200 KB
08 AC 9 ms 3200 KB
09 RE 122 ms 3200 KB
10 RE 122 ms 3200 KB
90 AC 4 ms 3200 KB
91 AC 4 ms 3200 KB