题目链接:http://codeforces.com/contest/131/problem/C 大意就是有n个男孩,m个女孩,从男孩中选不少于4个男孩,女孩中选不少于1个女孩,组成人数为t的队伍,问有几种可能的组合,高中的排列组合题目,组合数和杨辉三角形表是一一对应的,打一个表,依次对应着加和就可以了. AC代码: #include<iostream> #include<vector> #include<algorithm> using namespace std;…
题意:已知有n个男生,m个女生.现在要选t个人,要求有至少4个男生,至少1个女生,求有多少种选法. 分析: 1.展开,将分子中的m!与分母中n!相约,即可推出函数C. #pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio> #include<cstring> #include<cstdlib> #include<cctype> #include<…
[题目链接] http://codeforces.com/problemset/problem/785/D [题目大意] 给出一个只包含左右括号的串,请你找出这个串中的一些子序列, 要求满足"(((())))",即左边全是左括号右边全是右括号且数量相等的形式. 求这样的子序列的数量. [题解] 我们枚举每个断点(,计算当这个位置作为最后一个左括号时候的方案数 设左边有x个左括号,右边有y个右括号,那么统计答案为ΣC(x,i)*C(y,i+1) 又有C(y,i+1)=C(y,y-1-i)…
D. Anton and School - 2 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Br…
There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a gro…
You are given two integers nn and mm . Calculate the number of pairs of arrays (a,b)(a,b) such that: the length of both arrays is equal to mm ; each element of each array is an integer between 11 and nn (inclusive); ai≤biai≤bi for any index ii from 1…
题目 跑个案例看看结果就知道了:8 2 3 题目给的数据是 n,k,d 相当于高中数学题:k个人中选择d个人排成一列,有多少种不同的方案数,列出其中n中就可以了. #include<iostream> #include<algorithm> #include<string> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h>…
As Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent New Year Tree must be decorated with a good garland. Edward has lamps of m colors and he wants to mak…
Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [l, r] (1 ≤ l ≤ r ≤ m). Interval [l1, r1] belongs to interval [l2, r2] if the following condition is met:…
这个题相当于求从1-n的递增方案数,为C(2*n-1,n); 取模要用lucas定理,附上代码: #include<bits/stdc++.h> using namespace std; typedef long long LL; LL mod=1000000007; LL quick_mod(LL a,LL b){ LL ans=1%mod; while(b){ if(b&1){ ans=ans*a%mod; b--; } b>>=1; a=a*a%mod; } retu…