UVa 11609
来源:互联网 发布:索尼授权网络经销商 编辑:程序博客网 时间:2024/06/05 16:43
先找规律,然后猜结果,AC。。
后来看了题解,证明忘了,自己给了个证明,不是很巧妙
所求为 和式 k*c(n,k) k为[1,n]
它等于了 和式 c(n,k)*(n-k) k为[0,n-1]
两式相加 变成了 和式 c(n,k)*k k为[1,n-1] +c(n,n)*n+c(n,0)*n
即 n*∑ c(n,k) k为[0,n]
组合的意义是从n个数中选k个
所以上式为n*2^n
然后除以2
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <ctime>#include <cmath>#include <vector>#include <deque>#include <algorithm>#include <list>#include <map>#include <set>#include <queue>#include <stack>#define REP(i,n) for(int i=0;i<(n);i++)#define REP1(i,n) for(int i=1;i<=(n);i++)#define FOR(i,a,b) for (int i=(a);i<=(b);i++)#define CLR(x,n) memset(x,n,sizeof(x))#define PN printf("\n")#define read(x) scanf("%d",&x)#define read2(x,y) scanf("%d%d",&x,&y)#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)#define write(x) printf("%d",x)#define write1(x) printf("%d ",x)#define writeln(x) printf("%d\n",x)#define write2(x,y) printf("%d %d",x,y)#define writeln2(x,y) printf("%d %d\n",x,y)#define write3(x,y,z) printf("%d %d %d",x,y,z)#define writeln3(x,y,z) printf("%d %d %d\n",x,y,z)#define LL long long#define MOD 1000000007using namespace std;/*WA 输入4会输出16。。。快速幂写错 if p%2==1... */LL quickpow(LL p,LL q){ if (q==1)return p; if (q==0)return 1; LL ans=quickpow(p,q/2); ans=(ans*ans)%MOD; if (q%2==1)ans=(ans*p)%MOD; return ans;}int main(){ int t;read(t);LL n; REP(k,t){ scanf("%lld",&n); LL ans=( (n % MOD)*quickpow(2,n-1) ) % MOD; printf("Case #%d: %lld\n",k+1,ans); } system("pause"); return 0;}
- UVa 11609
- uva 11609
- uva 11609
- uva 11609(组合)
- UVa:11609 Teams
- UVa 11609 - Teams
- uva 11609 - Teams
- UVA 11609 Teams
- uva 11609 组合数学
- UVA 11609 (组合数学)
- Teams(UVA 11609)
- UVA 11609 Teams
- uva 11609Teams
- UVA-11609 Teams
- uva
- UVA
- UVA
- UVA
- 【收藏】林达华 概率模型与计算机视觉
- android properities 里面的 ”is library“
- 《编程之美》重建二叉树
- 百练 2810 完美立方
- 百练 2694 逆波兰表达式
- UVa 11609
- 链表的基础操作总结(链表创建,插入,删除,遍历等等)
- PE文件结构详解(一)基本概念
- 百练 3258 兔子产子
- 2013 成都赛区网赛 D Minimum palindrome
- 【Leetcode】Flatten Binary Tree to Linked List
- 百练 2693 最远距离
- debian 相关命令
- The Linux Kernel API