Submission #97311


Source Code Expand

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void pvp(T a, T b) { for (T i = a; i != b; ++i) cout << "(" << i->first << ", " << i->second << ") "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const int A = 65;
const int B = 45;
const int C = 35;

int N;
Int D;
double dp[110][70][50][40];

int main() {
	int i, a, b, c;
	
	for (; ~scanf("%d%lld", &N, &D); ) {
		Int d = D;
		int da = 0, db = 0, dc = 0;
		for (; d % 2 == 0; d /= 2) ++da;
		for (; d % 3 == 0; d /= 3) ++db;
		for (; d % 5 == 0; d /= 5) ++dc;
		if (d > 1) {
			puts("0");
			continue;
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0][0][0] = 1;
		for (i = 0; i < N; ++i) {
			for (a = 0; a < A; ++a) for (b = 0; b < B; ++b) for (c = 0; c < C; ++c) {
				if (dp[i][a][b][c] < 1e-100) {
					dp[i][a][b][c] = 0;
					continue;
				}
				double tmp = dp[i][a][b][c] / 6.0;
				dp[i + 1][a + 0][b + 0][c + 0] += tmp;
				dp[i + 1][a + 1][b + 0][c + 0] += tmp;
				dp[i + 1][a + 0][b + 1][c + 0] += tmp;
				dp[i + 1][a + 2][b + 0][c + 0] += tmp;
				dp[i + 1][a + 0][b + 0][c + 1] += tmp;
				dp[i + 1][a + 1][b + 1][c + 0] += tmp;
			}
		}
		double ans = 0;
		for (a = da; a < A; ++a) for (b = db; b < B; ++b) for (c = dc; c < C; ++c) {
			ans += dp[N][a][b][c];
		}
		printf("%.10f\n", ans);
	}
	
	return 0;
}

Submission Info

Submission Time
Task D - サイコロ
User hos_lyric
Language C++ (G++ 4.6.4)
Score 0
Code Size 2018 Byte
Status WA
Exec Time 283 ms
Memory 121024 KB

Compile Error

./Main.cpp: In function ‘int in()’:
./Main.cpp:31:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name All
Score / Max Score 0 / 4
Status
AC × 8
WA × 5
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 241 ms 121012 KB
01 WA 275 ms 121016 KB
02 AC 269 ms 121016 KB
03 AC 239 ms 121024 KB
04 AC 234 ms 121020 KB
05 WA 283 ms 120968 KB
06 WA 276 ms 121020 KB
07 WA 280 ms 121016 KB
08 AC 238 ms 121024 KB
09 WA 273 ms 121016 KB
10 AC 20 ms 784 KB
90 AC 227 ms 121012 KB
91 AC 226 ms 121016 KB