加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Cut the Cake(大数)

发布时间:2020-12-14 03:02:54 所属栏目:大数据 来源:网络整理
导读:Problem ? Link:http://acm.hdu.edu.cn/showproblem.php?pid=4762 Cut the Cake Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 849????Accepted Submission(s): 412 Problem Description MMM

Problem ? Link:http://acm.hdu.edu.cn/showproblem.php?pid=4762



Cut the Cake

Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 849????Accepted Submission(s): 412


Problem Description
MMM got a big big big cake,and invited all her M friends to eat the cake together. Surprisingly one of her friends HZ took some (N) strawberries which MMM likes very much to decorate the cake (of course they also eat strawberries,not just for decoration). HZ is in charge of the decoration,and he thinks that it's not a big deal that he put the strawberries on the cake randomly one by one. After that,MMM would cut the cake into M pieces of sector with equal size and shape (the last one came to the party will have no cake to eat),and choose one piece first. MMM wants to know the probability that she can get all N strawberries,can you help her? As the cake is so big,all strawberries on it could be treat as points.
?

Input
First line is the integer T,which means there are T cases.
For each case,two integers M,N indicate the number of her friends and the number of strawberry.
(2 < M,N <= 20,T <= 400)
?

Output
As the probability could be very small,you should output the probability in the form of a fraction in lowest terms. For each case,output the probability in a single line. Please see the sample for more details.
?

Sample Input
  
  
2 3 3 3 4
?

Sample Output
  
  
1/3 4/27
?

Source
2013 ACM/ICPC Asia Regional Changchun Online
?

Recommend
liuyiding???|???We have carefully selected several similar problems for you:?? 4988? 4987? 4986? 4985? 4984?
?
code:


#include<stdio.h> #include<string.h> int gcd(int a,int b) { if(b==0) return a; gcd(b,a%b); } int main() { int t,m,n,a[30],b1,b2,i,j,k,cnt,c; while(scanf("%d",&t)!=EOF) { while(t--) { scanf("%d%d",&m,&n); memset(a,sizeof(a)); a[1]=1; b1=n; cnt=1; for(i=1;i<=n-1;i++) { ? ?? ? ?b2=m; k=gcd(b1,b2); b1/=k; b2/=k; c=0; for(j=1;j<=cnt;j++) { a[j]=a[j]*b2+c; c=a[j]/10; a[j]%=10; } while(c) { a[++cnt]=c%10; c/=10; } } //for(i=cnt;i>=1;i--) //printf("%d ",a[i]); //printf("n"); printf("%d/",b1); for(i=cnt;i>=1;i--) printf("%d",a[i]); printf("n"); } } return 0; }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读