// UVa 10759 - Dice Throwing
#include <iostream>
using namespace std;
#define datatype unsigned long long int
datatype gcd(datatype a, datatype b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int main() {
int n, m;
cin >> n >> m;
while (n) {
datatype T[25][151];
T[0][0] = 1;
for (int i = 1; i <= n; i++)
T[i][0] = T[i - 1][0] * 6;
for (int j = 1; j <= m; j++)
T[0][j] = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
T[i][j] = 0;
for (int k = 1; k <= 6; k++) {
int kk = min(k, j);
T[i][j] += T[i - 1][j - kk];
}
}
}
datatype a = T[n][m];
datatype b = T[n][0];
if (a == 0)
cout << 0 << endl;
else if (a == b)
cout << 1 << endl;
else {
datatype g = gcd(b, a);
a /= g;
b /= g;
cout << a << "/" << b << endl;
}
cin >> n >> m;
}
return 0;
}
Thursday, September 17, 2015
UVa 10759 - Dice Throwing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment