Submission #1135019
Source Code Expand
#include <stdio.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
double dp[2][61][38][26];
int main(){
int l, i, j, k, n;
int n2, n3, n5;
long long int d;
scanf("%d%lld", &n, &d);
n2 = __builtin_ctzll(d);
d >>= n2;
for(n3=0;d%3==0;d/=3,n3++) ;
for(n5=0;d%5==0;d/=5,n5++) ;
if(d != 1){ puts("0"); return 0; }
dp[0][0][0][0] = 1.0;
for(l=0;l<n;l++){
int b = l & 1;
for(i=0;i<=n2;i++){
int i1 = MIN(n2, i+1);
int i2 = MIN(n2, i+2);
for(j=0;j<=n3;j++){
int j1 = MIN(n3, j+1);
for(k=0;k<=n5;k++){
int k1 = MIN(n5, k+1);
double tmp = dp[b][i][j][k]/6;
dp[b^1][i][j][k] += tmp;
dp[b^1][i1][j][k] += tmp;
dp[b^1][i][j1][k] += tmp;
dp[b^1][i2][j][k] += tmp;
dp[b^1][i][j][k1] += tmp;
dp[b^1][i1][j1][k] += tmp;
dp[b][i][j][k] = 0;
}
}
}
}
printf("%.7f\n", dp[l&1][n2][n3][n5]);
return 0;
}
Submission Info
Submission Time
2017-02-27 03:22:21+0900
Task
D - サイコロ
User
ryuhei
Language
C (GCC 5.4.1)
Score
4
Code Size
1004 Byte
Status
AC
Exec Time
1 ms
Memory
512 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:11:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%lld", &n, &d);
^
Judge Result
Set Name
All
Score / Max Score
4 / 4
Status
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
1 ms
128 KB
01
AC
1 ms
256 KB
02
AC
1 ms
256 KB
03
AC
1 ms
256 KB
04
AC
1 ms
256 KB
05
AC
1 ms
384 KB
06
AC
1 ms
512 KB
07
AC
1 ms
512 KB
08
AC
1 ms
512 KB
09
AC
1 ms
512 KB
10
AC
0 ms
128 KB
90
AC
1 ms
128 KB
91
AC
1 ms
128 KB