Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <algorithm>
- #include <limits>
- #include <vector>
- #include <cstdio>
- #include <cmath>
- #include <cstdlib>
- #include <cstring>
- #include <cctype>
- #include <ctime>
- using namespace std;
- unsigned long long int ar[30][200];
- unsigned long long int power(unsigned long long int x, unsigned long long int n)
- {
- int i, j, k;
- unsigned long long int z = 1;
- if (n == 0) return 1;
- else if (n == 1) return x;
- else if (n % 2 == 0) z = (power(x, (n / 2)) * power(x, (n / 2)));
- else z = x * power(x, ((n - 1) / 2)) * power(x, ((n - 1) / 2));
- return z;
- }
- unsigned long long int GreatestCommonDivisor(unsigned long long int a, unsigned long long int b)
- {
- if (b == 0) return a;
- GreatestCommonDivisor(b, (a % b));
- }
- int main()
- {
- int i, j, k, l, n;
- unsigned long long int x, y, z, a, b, c, d;
- ar[1][0] = 0;
- for (i = 1; i <= 150; i++)
- {
- if (i <= 6) ar[1][i] = 1;
- else ar[1][i] = 0;
- }
- for (n = 2; n <= 24; n++)
- {
- for (i = 0; i < n; i++) ar[n][i] = 0;
- for (; i <= (6 * n); i++)
- {
- x = 0;
- for (j = 1; j <= 6; j++)
- {
- l = i - j;
- y = ar[n - 1][l];
- x += y;
- }
- ar[n][i] = x;
- }
- for (; i <= 150; i++) ar[n][i] = 0;
- }
- for (; ;)
- {
- scanf("%d %d", &n, &i);
- if (n == 0 && i == 0) break;
- x = power(6, n), y = 0;
- for (j = i; j <= (6 * n); j++) y += ar[n][j];
- z = GreatestCommonDivisor(y, x);
- y /= z, x /= z;
- if (x == 1 || y == 0) printf("%llu\n", y);
- else printf("%llu/%llu\n", y, x);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement