BestCoder Round #35

A

题意:给出n个黑球,m个白球,每次取1个球,取了n+m次以后,会生成一个随机的01串S,

如果第i次取出的是黑球,则s[i]=1,如果是白色的,那么s[i]=0, 问01串在S中出现的期望次数

 大概可以这样算,是因为取出一个01串之后,其他的有两个01串,三个01串,四个01串的情况都包含在里面,所以只需要算出一个01串的有多少种情况就可以了

 1 #include<iostream>  
 2 #include<cstdio>  
 3 #include<cstring> 
 4 #include <cmath> 
 5 #include<stack>
 6 #include<vector>
 7 #include<map> 
 8 #include<set>
 9 #include<queue> 
10 #include<algorithm>  
11 #define mod=1e9+7;
12 using namespace std;
13 
14 typedef long long LL;
15 
16 LL jiecheng(int a){
17     LL ans=1;
18     for(int i=1;i<=a;i++)
19     ans*=i;
20     return ans;
21 }
22 
23 LL gcd(LL a,LL b){
24     return b==0? a:gcd(b,a%b);
25 }
26 
27 int main(){
28     int n,m,i;
29     while(scanf("%d %d",&n,&m)!=EOF){
30         int a=(n*m);
31         int b=n+m;
32         int xx=gcd(a,b);
33         a=a/xx;
34         b=b/xx;
35         printf("%d/%d\n",a,b);
36     }return 0;
37 }
View Code

 

 

最开始的时候用next_permutation ,到 9 12就跑不出来了

后来才知道要状态压缩= =

 

 

B

给出一张有向无环图,要求在最多删去k条边之后,求出字典序最大的拓扑排序

不会= = 看题解说要用到线段树= =

 

挖坑

 

转载于:https://www.cnblogs.com/wuyuewoniu/p/4375562.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值