UVa 10446 求(n,bcak)递归次数.自己推出来了一个式子: 其实就是这个式子,但是不知道该怎么写,怕递归写法超时.其实直接递推就好,边界条件易得C(0,back)=1.C(1,back)=1. Reference Code: #include<iostream> #include<cstdio> using namespace std; typedef unsigned long long ll; ll dp[][]={}; int main() { int n,bac…
有n张牌,求出至少有k张牌连续是正面的排列的种数.(1=<k<=n<=100) Toss is an important part of any event. When everything becomes equal toss is the ultimate decider. Normally a fair coin is used for Toss. A coin has two sides head(H) and tail(T). Superstition may work in…
GRAVITATION, n.“The tendency of all bodies to approach one another with a strengthproportion to the quantity of matter they contain – the quantity ofmatter they contain being ascertained by the strength of their tendencyto approach one another. This…
除了根节点以外,有n-1个节点,然后就看n-1的因数有那些,所有因数加起来(递推)就好了. #include<cstdio> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MOD = 1e9 + 7; const int MAXN = 1123; int ans[MAXN]; void init() { ans[1] = 1; REP(i, 2, MAXN) REP(j…
这道题有点类似动态规划,设答案为f(n) 第一个人有i个人,就有c(n,i)种可能 然后后面有f(n-i)种可能,所以相乘,然后枚举所有可能加起来就ok了. #include<cstdio> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 1123; const int MOD = 10056; int c[MAXN][MAXN], f[MAXN]; voi…
从大到小安排杆子 分三种情况 (1)插到最左边,那么左边看到了杆子会多一个 (2)插到最右边,那么右边看到了杆子会多一个 (3)插到中间边,那么不影响左边和右边看到的杆子数 具体看代码 #include<cstdio> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 21; long long d[MAXN][MAXN][MAXN]; int main()…
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Series-Parallel Networks Input: standard input Output: standard output Time Limit: 5 seconds Memory Limit: 32 MB In this problem you are expected to count two-terminal series-parallel networ…