Submission #6412223
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[2][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)%2][j][k][l] += dp[i%2][j][k][l] / 6.0; dp[(i+1)%2][j+1][k][l] += dp[i%2][j][k][l] / 6.0; dp[(i+1)%2][j][k+1][l] += dp[i%2][j][k][l] / 6.0; dp[(i+1)%2][j+2][k][l] += dp[i%2][j][k][l] / 6.0; dp[(i+1)%2][j][k][l+1] += dp[i%2][j][k][l] / 6.0; dp[(i+1)%2][j+1][k+1][l] += dp[i%2][j][k][l] / 6.0; // dp[i%2][j][k][l] = 0.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%2][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 | 1628 Byte |
Status | WA |
Exec Time | 663 ms |
Memory | 30848 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 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 | 16 ms | 13312 KB |
01 | WA | 484 ms | 28672 KB |
02 | WA | 344 ms | 26496 KB |
03 | WA | 23 ms | 13440 KB |
04 | WA | 21 ms | 13440 KB |
05 | WA | 663 ms | 30848 KB |
06 | WA | 462 ms | 28672 KB |
07 | WA | 380 ms | 26496 KB |
08 | AC | 4 ms | 6912 KB |
09 | WA | 327 ms | 26496 KB |
10 | AC | 1 ms | 256 KB |
90 | AC | 2 ms | 2304 KB |
91 | WA | 2 ms | 2304 KB |