1. /*
  2. C(n,k)
  3. */
  4. #include<iostream>
  5. #include<cstdio>
  6. #include<cstring>
  7.  
  8. #define ll long long
  9. #define N 1000007
  10. #define M 1000000007
  11.  
  12. using namespace std;
  13. ll n,k,ans,cnt1,cnt0;
  14. ll inv[N]={,},fac[N]={,},f[N]={,};
  15.  
  16. inline ll read()
  17. {
  18. int x=,f=;char c=getchar();
  19. while(c>''||c<''){if(c=='-')f=-;c=getchar();}
  20. while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
  21. return x*f;
  22. }
  23.  
  24. inline void init()
  25. {
  26. for(int i=;i<=N;i++)
  27. {
  28. fac[i]=(fac[i-]%M*i%M)%M;
  29. f[i]=((M-M/i)%M*f[M%i])%M;
  30. inv[i]=(inv[i-]*f[i]%M)%M;
  31. }
  32. }
  33.  
  34. inline ll C(ll a,ll b)
  35. {
  36. return fac[a]%M*inv[b]%M*inv[a-b]%M;
  37. }
  38.  
  39. int main()
  40. {
  41. freopen("cube.in","r",stdin);
  42. freopen("cube.out","w",stdout);
  43. n=read();k=read();init();
  44. printf("%I64d\n",C(n,k));
  45. return ;
  46. }

  1. /*
  2. 做最大生成树时标记哪些边被加了进去。然后把这些边排序。
  3. 如果询问权值w的货物,就在边中查找小于w的最大值假设拍第k大
  4. 答案就是k+1。 复杂度O(qlogn)
  5. */
  6. #include<iostream>
  7. #include<cstdio>
  8. #include<cstring>
  9. #include<algorithm>
  10.  
  11. #define N 100007
  12.  
  13. using namespace std;
  14. int n,m,q,ans,cnt,num;
  15. int head[N],fa[N];
  16. struct edge{
  17. int u,v,w,net,pos;
  18. bool operator < (const edge &a) const{
  19. return w>a.w;
  20. }
  21. }e[N<<],E[N],tmp[N<<];
  22.  
  23. inline int read()
  24. {
  25. int x=,f=;char c=getchar();
  26. while(c>''||c<''){if(c=='-')f=-;c=getchar();}
  27. while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
  28. return x*f;
  29. }
  30.  
  31. inline void add(int u,int v,int w)
  32. {
  33. e[++cnt].u=u;e[cnt].v=v;e[cnt].w=w;
  34. e[cnt].net=head[u];head[u]=cnt;
  35. }
  36.  
  37. int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
  38.  
  39. void kruskal()
  40. {
  41. int r1,r2;
  42. sort(E+,E+m+);
  43. for(int i=;i<=m;i++)
  44. {
  45. r1=find(E[i].u),r2=find(E[i].v);
  46. if(r1==r2)continue;
  47. fa[r1]=r2;num++;
  48. add(E[i].u,E[i].v,E[i].w);add(E[i].v,E[i].u,E[i].w);
  49. tmp[num].pos=num;tmp[num].u=E[i].u,tmp[num].v=E[i].v;tmp[num].w=E[i].w;
  50. if(num==n-) break;
  51. }
  52. }
  53.  
  54. int serch(int x)
  55. {
  56. int l=,r=n-,mid;
  57. while(l<=r)
  58. {
  59. mid=l+r>>;
  60. if(tmp[mid].w>=x) l=mid+;
  61. else ans=mid,r=mid-;
  62. }return num-ans+;
  63. }
  64.  
  65. int main()
  66. {
  67. freopen("warehouse.in","r",stdin);
  68. freopen("warehouse.out","w",stdout);
  69. int x,y,z,k;
  70. n=read();m=read();q=read();
  71. for(int i=;i<=n;i++) fa[i]=i;
  72. for(int i=;i<=m;i++)
  73. {
  74. E[i].u=read();E[i].v=read();E[i].w=read();
  75. }kruskal();
  76. for(int i=;i<=q;i++)
  77. {
  78. x=read();
  79. if(x<=e[cnt].w){printf("1\n");continue;}
  80. if(x>e[].w){printf("%d\n",n);continue;}
  81. k=serch(x);
  82. printf("%d\n",k+);
  83. }
  84. return ;
  85. }

清北考前刷题day5早安的更多相关文章

  1. 清北考前刷题day4早安

      LI /* 没有考虑次大值有大于一个的情况 */ #include<iostream> #include<cstdio> #include<cstring> # ...

  2. 清北考前刷题day7早安

  3. 清北考前刷题day6早安

    #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #d ...

  4. 清北考前刷题day2早安

    /* 做法一:按h sort一遍,对于一段区间[i,j],高度花费就是h[j]-h[i] 然后枚举区间,把区间内C排序,一个一个尽量选即可. n^3logn 标算:n^3 dp 高度排序,保证从前往后 ...

  5. 清北考前刷题day1早安

    立方数(cubic) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK定义了一个数叫“立方数”,若一个数可以被写作是一个正整数的3次方,则这个数就是立方数 ...

  6. 清北考前刷题day1下午好

    水题(water) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK出了道水题. 这个水题是这样的:有两副牌,每副牌都有n张. 对于第一副牌的每张牌长和宽 ...

  7. 清北考前刷题da7下午好

    三向城 /* 原图一定是一棵完全二叉树. 根节点是x,左节点是x*2,右节点是x*2+1 转化为二进制往左右走就很明显了. */ #include<iostream> #include&l ...

  8. 清北考前刷题day6下午好

    /* 贪心 负数一定不取 枚举最高位是1 且答案取为0的 位置, 更新答案. */ #include<iostream> #include<cstdio> #include&l ...

  9. 清北考前刷题da5下午好

    /* (4,1)*(3,1)*(2,1)的话1变成2然后一直是2 2变成1然后变成3 3变成1然后变成4 4变成1 */ #include<iostream> #include<cs ...

随机推荐

  1. Qt5笔记之数据库(五)SQL表格模型QSqlTableModel

    教程网址:http://www.qter.org/portal.php?mod=view&aid=57 0.打开tablemodel.pro文件,加上: QT += coregui sql 注 ...

  2. javaWeb学习之 Filter过滤器----https://www.cnblogs.com/xdp-gacl/p/3948353.html

    https://www.cnblogs.com/xdp-gacl/p/3948353.html

  3. 九度oj 题目1063:整数和

    题目1063:整数和 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4043 解决:2638 题目描述: 编写程序,读入一个整数N.若N为非负数,则计算N到2N之间的整数和:若N为一个负数 ...

  4. Apple & APPID & iOS & React Native

    Apple & APPID & iOS & React Native 在没有 苹果开发者账号证书 APPID, ios 是否支持导出 app https://developer ...

  5. [bzoj1510][POI2006]Kra-The Disks_暴力

    Kra-The Disks bzoj-1510 POI-2006 题目大意:题目链接. 注释:略. 想法:不难发现其实只有前缀最小值是有效的. 进而我们把盘子一个一个往里放,弄一个自底向上的指针往上蹦 ...

  6. cocos2d-x CCScrollView和CCTableView的使用

    在游戏和应用中常常要实现左右滑动展示游戏帮助.以列表显示内容的UI效果,就像android中的Gallery和ListView. 本文通过CCScrollView和CCTableView分别来实现这两 ...

  7. html实现类似excel的复杂表格,及导出到excel

    1. excellentexport.js https://github.com/jmaister/excellentexport/tree/2.0.3 2.fiddle example  https ...

  8. MySQL 高可用架构在业务层面的分析研究

    )读多写少 虚线表示跨机房部署,比方电子商务系统.一个Master既有读也有些写.对读数据一致性须要比較重要的.读要放在Master上面. M(R)仅仅是一个备库.仅仅有M(WR)挂了之后,才会切换到 ...

  9. 编程算法 - 两个升序列的同样元素 代码(C)

    两个升序列的同样元素 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 两个升序列的同样元素, 须要使用两个指针, 依次遍历, 假设相等输出, 假设小于或 ...

  10. Python输入输出及其他

    print用法 print会输出一个\n,也就是换行符,这样光标移动到了下一行行首,接着输出,之前已经通过stdout输出的东西依旧保留,而且保证我们在下面看到最新的输出结果.回车 \r 本义是光标重 ...