zoukankan      html  css  js  c++  java
  • 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
    ",a,b);
    36     }return 0;
    37 }
    View Code

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

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

    B

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

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

    挖坑

  • 相关阅读:
    Python列表生成
    Python 多线程
    Python面向对象编程
    map, reduce和filter(函数式编程)
    35个高级python知识点
    python之pyc
    Python之简单的用户名密码验证
    EasyUI 实例
    hibernate映射文件one-to-one元素属性
    Java中多对多映射关系
  • 原文地址:https://www.cnblogs.com/wuyuewoniu/p/4375562.html
Copyright © 2011-2022 走看看