Submission #6360093


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;

ll dp[2][210][105][105];

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]=1;
    int cur=0;
    int next=1;
    ll ans=0;
    rep(i,n){
        rep(j,201) rep(k,101) rep(l,101) dp[next][j][k][j]=0;
        rep(j,201) rep(k,101) rep(l,101){
        dp[next][j][k][l]+=dp[cur][j][k][l];
        dp[next][j+1][k][l]+=dp[cur][j][k][l];
        dp[next][j][k+1][l]+=dp[cur][j][k][l];
        dp[next][j+2][k][l]+=dp[cur][j][k][l];
        dp[next][j][k][l+1]+=dp[cur][j][k][l];
        dp[next][j+1][k+1][l]+=dp[cur][j][k][l];
        }

        swap(cur,next);
        
    }
            rep(i,a,210) rep(j,b,105) rep(k,c,105){
        ans+=dp[cur][i][j][k];
        }
    double res=(double)ans/pow(6,n);
    cout<<fixed<<setprecision(14)<<res<<endl;
}

Submission Info

Submission Time
Task D - サイコロ
User meimon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1647 Byte
Status WA
Exec Time 645 ms
Memory 35840 KB

Compile Error

In function ‘int main()’:
cc1plus: warning: iteration 105u invokes undefined behavior [-Waggressive-loop-optimizations]
./Main.cpp:11:39: note: containing loop
 #define repi(i,a,b) for(int i=int(a);i<int(b);++i)
                                       ^
./Main.cpp:10:19: note: in expansion of macro ‘repi’
 #define _rep(i,n) repi(i,0,n)
                   ^
./Main.cpp:9:39: note: in expansion of macro ‘_rep’
 #define _overload3(_1,_2,_3,name,...) name
                                       ^
./Main.cpp:12:18: note: in expansion of macro ‘_overload3’
 #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
                  ^
./Main.cpp:46:9: note: in expansion of macro ‘rep’
         rep(j,201) rep(k,101) rep(l,101) dp[next][j][k][j]=0;
         ^

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
AC × 4
WA × 9
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 236 ms 35840 KB
01 WA 595 ms 35840 KB
02 WA 545 ms 35840 KB
03 WA 264 ms 35840 KB
04 WA 256 ms 35840 KB
05 WA 645 ms 35840 KB
06 WA 590 ms 35840 KB
07 WA 559 ms 35840 KB
08 AC 130 ms 35840 KB
09 WA 538 ms 35840 KB
10 AC 1 ms 256 KB
90 AC 25 ms 35840 KB
91 WA 32 ms 35840 KB