Submission #6331947


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double dp[2][80][50][30];
int main(){
   ll n,d;
   cin>>n>>d;
   int p2=0,p3=0,p5=0;
   bool flag=true;
  while(flag){
      flag=false;
      if(d%2==0){d/=2;p2++;flag=true;}
      if(d%3==0){d/=3;p3++;flag=true;}
      if(d%5==0){d/=5;p5++;flag=true;}
  }
    if(d!=1){printf("%.10lf\n",0);return 0;}
  memset(dp,0.0,sizeof(dp));
  dp[0][0][0][0]=1.0;
  for(int i=0;i<n;i++){
  for(int dp2=0;dp2<=p2;dp2++)for(int dp3=0;dp3<=p3;dp3++)for(int dp5=0;dp5<=p5;dp5++){
      for(int j=1;j<=6;j++){
    int np2=min(p2,(j==2||j==6?dp2+1:(j==4?dp2+2:dp2)));
    int np3=min(p3,(j%3==0?dp3+1:dp3));
    int np5=min(p5,(j==5?dp5+1:dp5));
    dp[(i+1)&1][np2][np3][np5]+=dp[i&1][dp2][dp3][dp5]/6.0;
      }
    dp[i&1][dp2][dp3][dp5]=0;
  }
  }
printf("%.10lf\n",dp[n&1][p2][p3][p5]);
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:33: warning: format ‘%lf’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
     if(d!=1){printf("%.10lf\n",0);return 0;}
                                 ^

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 2 ms 2176 KB
01 AC 4 ms 2176 KB
02 AC 3 ms 2176 KB
03 AC 3 ms 2176 KB
04 AC 2 ms 2176 KB
05 AC 4 ms 2176 KB
06 AC 4 ms 2176 KB
07 AC 3 ms 2176 KB
08 AC 2 ms 2176 KB
09 AC 2 ms 2176 KB
10 AC 1 ms 256 KB
90 AC 2 ms 2176 KB
91 AC 2 ms 2176 KB