- 博客(11)
- 收藏
- 关注
原创 动态规划公式
-----石子合并 F[i,j]:=min(f[i,k]+f[k+1,j]+sum[i,j]); 5. 剖分问题2 -----多边形剖分 F[I,j]:=min(f[i,k]+f[k,j]+a[k]*a[j]*a[i]); 6. 剖分问题3 ------乘积最大 f[i,j]:=max(f[k,j-1]*mult[k,i]); 7. 树型动态规划1 -----加
2013-07-19 09:56:58
776
转载 背包问题
01 背包有n 种不同的物品,每个物品有两个属性,size 体积,value 价值,现在给一个容量为 w 的背包,问最多可带走多少价值的物品。 int f[w+1]; //f[x] 表示背包容量为x 时的最大价值 for (int i=0; i for (int j=w; j>=size[i]; j--)
2013-07-19 09:55:14
420
转载 最大子序列
问题描述 给定(可能是负的)整数序列A1, A2,...,AN, 寻找(并标识)使Sum(Ak)(k >=i, k 最简单暴力的解法 这个问题有一个最简单直接的穷举解决法。我们看问题,既然要求里面最大的连续子序列。那么所有的连续子序列将由哪些组成呢?以数组的第一个元素为例,连续子序列必须是至少包含元素A1,也可能包含从A1到A2...以
2013-07-15 21:02:25
612
原创 HARD PROBLEM
The cat gets N mice from dreamone, and she can choose K mice from them as the order which is listed from left to right for dinner. But there is a limitation that the second mouse is no bigger than t
2013-07-14 10:23:29
417
原创 ARITHMETIC PROGRESSION
#include#includeint dp[100005],a[100005];int main(){ int i,j,n,max=0; while(scanf("%d",&n)!=EOF) { max=0; memset(dp,0,sizeof(dp)); // 等价于for(i=0;i memset(a,0,sizeof
2013-07-11 20:40:04
526
原创 Dating With Girls
#include#include#include#define MAX 1100using namespace std;int map[105][105],val[105],mm[105],n;//map[][]存边,注意题目是有向图。val[]存每个点的权值。mm[i]存在i点能得到的最大权值。bool inq[105];//inq[i]标记i点是否在队列里,true表示
2013-07-11 20:38:04
559
原创 Matrix
To ecient calculate the multiplication of a sparse matrix is very useful in industrial led. Let's considerthis problem:A is an N*N matrix which only contains 0 or 1. And we want to know the resul
2013-07-11 20:36:38
420
原创 B. Strings of Power
B. Strings of PowerVolodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.Volodya calls a strin
2013-07-08 10:25:53
426
原创 a^b%c
#include #includeusing namespace std;int main(){int a,b,c,t;while(cin>>a>>b>>c){ t=1; for(int i=0;i t*=a; t=t%c; } cout} return 0;}
2013-07-06 14:27:58
486
原创 蜗牛快跑
#includeusing namespace std;int n,h,i,j;void make(){ int k; if (h { cout return; } if (i { cout return; } k=(h-i
2013-07-06 14:25:56
505
原创 A. Even Odds
A. Even OddsBeing a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determine
2013-07-06 11:12:57
635
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人