a=[[-1 for x in range(24*6+1)]for y in range (24+1)]
def rec(dice,sum):
if dice==0 and sum==0:
return 1
elif sum<=0:
return 0
elif dice<=0:
return 0
elif a[dice][sum]!=-1:
return a[dice][sum]
ans=0
for i in range(1,min(6,sum)+1):
ans+=rec(dice-1,sum-i)
a[dice][sum]=ans
return ans
def gcd(a,b):
if a==0:
return b
return gcd(b%a,a)
def Main():
[n,x]=input().split()
[n,x]=[int(n),int(x)]
a[0][0]=1
while n>0:
num=0
for i in range(x,24*6+1):
num+=rec(n,i)
den=6**n
f=gcd(num,den)
num//=f
den//=f
if den>1:
print("%d/%d"%(num,den))
else:
print(num)
[n,x]=input().split()
[n,x]=[int(n),int(x)]
if __name__=='__main__':
Main()
def rec(dice,sum):
if dice==0 and sum==0:
return 1
elif sum<=0:
return 0
elif dice<=0:
return 0
elif a[dice][sum]!=-1:
return a[dice][sum]
ans=0
for i in range(1,min(6,sum)+1):
ans+=rec(dice-1,sum-i)
a[dice][sum]=ans
return ans
def gcd(a,b):
if a==0:
return b
return gcd(b%a,a)
def Main():
[n,x]=input().split()
[n,x]=[int(n),int(x)]
a[0][0]=1
while n>0:
num=0
for i in range(x,24*6+1):
num+=rec(n,i)
den=6**n
f=gcd(num,den)
num//=f
den//=f
if den>1:
print("%d/%d"%(num,den))
else:
print(num)
[n,x]=input().split()
[n,x]=[int(n),int(x)]
if __name__=='__main__':
Main()
Comments
Post a Comment