- #include<stdio.h>
- #include<string.h>
- long long c[25][151];
- long long m[25][151];
- long long gcd(long long a, long long b){
- long long r;
- while(b != 0){
- r = a%b;
- a = b;
- b = r;
- }
- return a;
- }
- int main(){
- int i, j, g;
- long long k, t;
- memset(c, 0, sizeof(c));
- for(i=1; i<=6; i++){
- c[1][i] = 1;
- m[1][i] = 6;
- }
- for(i=2, k=36; i<=24; i++, k*=6){
- for(j=1; j<=150; j++){
- for(g=1; j-g>0 && g<=6; g++){
- if(j - g > 0)
- c[i][j] += c[i-1][j - g];
- }
- m[i][j] = k;
- }
- }
- while(1){
- scanf("%d %d", &i, &j);
- if(i == 0 && j == 0) break;
- t = 0;
- for(g=j; g<=6*i; g++){
- t += c[i][g];
- }
- if(t != 0){
- if(t != m[i][j]){
- k = gcd(m[i][j], t);
- if(k != 1){
- t /= k;
- m[i][j] /= k;
- }
- printf("%lld/%lld\n", t, m[i][j]);
- }else{
- puts("1");
- }
- }else{
- printf("0\n");
- }
- }
- getchar();
- return 0;
- }
Raw Paste