uva 11609】的更多相关文章

题目链接 想了一会,应该是跟二项式系数有关系,无奈自己推的式子,构不成二项式的系数. 选1个人Cn1*1,选2个人Cn2*2....这样一搞,以为还要消项什么的... 搜了一下题解,先选队长Cn1,选一个人的时候Cn-1 0,选2个人的时候Cn-1 1这样就构成二项式系数了. 一约,n*2^n-1...最后,还忘了取模,错了好多次.. #include <cstdio> #include <cstring> #include <string> #include <…
In a galaxy far far away there is an ancient game played among the planets. The specialty of the gameis that there is no limitation on the number of players in each team, as long as there is a captain inthe team. (The game is totally strategic, so so…
可以想到 答案为 1*C(1,n)+2*C(2,n)+3*C(3,n)+....+n*C(n,n); 由公式 k*C(k,n) = n*C(k-1,n-1) 所以最终答案 n*2^(n-1) 用到快速幂取余 #include <cstdio> #include <cstdlib> #include <cmath> #include <map> #include <set> #include <stack> #include <v…
n个人里选k个人有C(n, k)中方法,再从里面选一人当队长,有k中方法. 所以答案就是 第一步的变形只要按照组合数公式展开把n提出来即可. #include <cstdio> typedef long long LL; ; LL pow(int p) { LL ans = , ; while(p) { ) ans = (ans * base) % M; p >>= ; base = (base * base) % M; } return ans; } int main() { /…
题意:有n个人,选不少于一个人参加比赛,其中一人当队长,有多少种选择方案. 思路:我们首先C(n,1)选出一人当队长,然后剩下的 n-1 人组合的总数为2^(n-1),这里用快速幂解决 代码: #include <iostream> #define ll long long using namespace std; ; ll qmod(ll a, ll b) { ll ans=; while(b) { ) { ans=(ans*a)%mod; } b=b/; a=(a*a)%mod; } re…
题意就不多说了这个小规律不算难,比较容易发现,就是让你求一个数n*2^(n-1):很好想只是代码实现起来还是有点小困(简)难(单)滴啦,一个快速幂就OK了: 代码: #include<stdio.h> #define mod 1000000007 #define ll long long ll pow(ll a,ll b) { ll ans=; while(b) { >) ans=ans*a%mod; a=a*a%mod; b/=; } return ans; } int main()…
写的话就是排列组合...但能化简...ΣC(n,i)*C(i,1) 化简为n*2^(n-1) ; #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <set> #include <vector> #include <stack> #include <queu…
In a galaxy far far awaythere is an ancient game played among the planets. The specialty of the game isthat there is no limitation on the number of players in each team, as long asthere is a captain in the team. (The game is totally strategic, so som…
https://vjudge.net/problem/UVA-11609 题意: 有n个人,选一个或多个人参加比赛,其中一名当队长,有多少种方案?如果参赛者完全相同,但队长不同,算作不同的方案. 思路: 之后就是快速幂处理. #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<vector> #include<queue>…
Lily: “Chantarelle was part of my exotic phase.”Buffy: “It’s nice. It’s a mushroom.”Lily: “It is? That’s really embarrassing.”Buffy: “Well, it’s an exotic mushroom, if that’s any comfort.”Joss Whedon, "Anne".A little girl whose name is Anne Spetri…