Submission #3780194
Source Code Expand
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン!!!!
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
ll to, cost;
};
struct E {//辺の情報を入れる変数
ll from, to, cost;
};
bool operator<(E a, E b) {
return a.cost < b.cost;
}
struct H {
ll x, y;
};
bool operator<(H a, H b) {
if (a.x != b.x) return a.x < b.x;
return a.y < b.y;
}
bool operator>(H a, H b) {
if (a.x != b.x) return a.x > b.x;
return a.y > b.y;
}
bool operator==(H a, H b) {
return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
return a.x != b.x || a.y != b.y;
}
struct LS {
ll num, cost;
//値、遅延配列
};
ll gcm(ll i, ll j) {//最大公約数
if (i > j) swap(i, j);
if (i == 0) return j;
return gcm(j%i, i);
}
ld rad(H a, H b) {
return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad=座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
ll sum = 1;
for (int i = 0; i < k; i++) {
sum *= (x--);
sum %= p;
}
return sum;
}//階乗(正)
ll mod_pow(ll x, ll n, ll p) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * x%p;
x = x * x%p;
n >>= 1;
}
return res;
}//x^n%p
short ctos(char a) {
return (int)(a - '0');
}
const ll Inf = 4523372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, d;
ld dp[100][40][30][20];
//i, two, tre, five
int two, tre, five;
signed main() {
cin >> n >> d;
while (d % 2 == 0) {
two++;
d /= 2;
}
while (d % 3 == 0) {
tre++;
d /= 3;
}
while (d % 5 == 0) {
five++;
d /= 5;
}
if (d != 1) {
cout << 0 << endl;
return 0;
}
dp[0][0][0][0] = 1;
//2^0 * 3^0 * 5^0
for (int i = 0; i < n; i++) {
for (int x = 0; x <= two; x++) {
for (int y = 0; y <= tre; y++) {
for (int z = 0; z <= five; z++) {
dp[i + 1][x][y][z] += dp[i][x][y][z] / 6;
dp[i + 1][min(two, x + 1)][y][z] += dp[i][x][y][z] / 6;
dp[i + 1][x][min(tre, y + 1)][z] += dp[i][x][y][z] / 6;
dp[i + 1][x][y][min(five, z + 1)] += dp[i][x][y][z] / 6;
dp[i + 1][min(two, x + 2)][y][z] += dp[i][x][y][z] / 6;
dp[i + 1][min(two, x + 1)][min(tre, y + 1)][z] += dp[i][x][y][z] / 6;
}
}
}
}
ld ans = dp[n][two][tre][five];
printf("%.11LF\n", ans);
}
Submission Info
Submission Time |
|
Task |
D - サイコロ |
User |
Thistle |
Language |
C++14 (Clang 3.8.0) |
Score |
0 |
Code Size |
3268 Byte |
Status |
WA |
Exec Time |
11 ms |
Memory |
33408 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 |
WA |
3 ms |
10496 KB |
01 |
AC |
10 ms |
31232 KB |
02 |
WA |
8 ms |
27008 KB |
03 |
AC |
5 ms |
12800 KB |
04 |
AC |
5 ms |
12928 KB |
05 |
AC |
11 ms |
33408 KB |
06 |
AC |
10 ms |
32000 KB |
07 |
AC |
9 ms |
29952 KB |
08 |
AC |
4 ms |
7424 KB |
09 |
AC |
8 ms |
27520 KB |
10 |
AC |
1 ms |
256 KB |
90 |
AC |
1 ms |
256 KB |
91 |
AC |
1 ms |
256 KB |