Submission #6412187


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;

int N;
ll D;
double dp[100][10000][100][100];

int main(void){
    cin >> N >> D;
    int two = 0, three = 0, five = 0;
    while(D%2 == 0){
        D /= 2;
        two++;
    }
    while(D%3 == 0){
        D /= 3;
        three++;
    }
    while(D%5 == 0){
        D /= 5;
        five++;
    }
    if(D > 1){
        cout << "0" << '\n';
        return 0;
    }

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

        }
    }

    double res = 0;
    for(int i = two; i <= 2*N; i++){
        for(int j = three; j <= N; j++){
            for(int k = five; k <= N; k++){
                // printf("%d, %d, %d: %lf\n", i, j, k, dp[N][i][j][k]);
                res += dp[N][i][j][k];
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Submission Info

Submission Time
Task D - サイコロ
User yna87
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1542 Byte
Status CE

Compile Error

/tmp/ccyJHWfs.o: In function `main':
Main.cpp:(.text.startup+0x5): relocation truncated to fit: R_X86_64_32 against symbol `N' defined in .bss section in /tmp/ccyJHWfs.o
Main.cpp:(.text.startup+0x1e): relocation truncated to fit: R_X86_64_32 against symbol `D' defined in .bss section in /tmp/ccyJHWfs.o
Main.cpp:(.text.startup+0x2d): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccyJHWfs.o
Main.cpp:(.text.startup+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccyJHWfs.o
Main.cpp:(.text.startup+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccyJHWfs.o
Main.cpp:(.text.startup+0x127): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccyJHWfs.o
Main.cpp:(.text.startup+0x137): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccyJHWfs.o
/tmp/ccyJHWfs.o: In function `_GLOBAL_...