注意数组的大小,以及字符的输入问题
#include
#include
int dp[4000000],a[4],money[400];
char s[120];
double str[120];
int max(int a,int b)
{return a>b?a:b;}
int main()
{
int N,sum,ans,ok,count,i,j,num;
double Q...
分类:
其他好文 时间:
2014-07-26 02:38:26
阅读次数:
253
DFS
题意是让你把这些木棍组合成长度相等的一些木棍。要求长度最短。
#include
#include
#include
#include
using namespace std;
int a[65],n,sum,ans;
bool v[65],ok;
bool cmpa(int a,int b)
{
return a>b;
}
bool dfs(int num,int ne...
分类:
其他好文 时间:
2014-07-26 02:37:26
阅读次数:
130
#include
#include
#include
int s[1050];
int dp[1050];
int cmp(const void *a,const void * b)
{
return *(int *)b-*(int *)a;
}
int maxx(int a,int b)
{return a>b?a:b;}
int main()
{
int n,i,j,sum,MA...
分类:
其他好文 时间:
2014-07-26 02:20:36
阅读次数:
193
#include
main()
{
int n,k;
float score,sum,ave;
for(n=1;n<3;n++)
{ sum=0.0;
for(k=1;k<=4;k++)
{scanf("%f",&score);
sum+=score;
}
ave=sum/4.0;
printf("NO%d:%f\n",n,ave);
}
}
sum=0.0的位置...
分类:
其他好文 时间:
2014-07-26 02:04:36
阅读次数:
201
1. 将一个数组分成左右两部分,使得右边的某个连续子段和减去左边的某个连续字段和最小[7,8,9,|3,5,-1] sum right - sum left minimal想到左右分一刀,O(n),然后对左右分别取最大字段和算法,这样是O(n^2)。但是其实左右各扫一遍,然后记录下来就行了。int ...
分类:
其他好文 时间:
2014-07-26 01:50:46
阅读次数:
219
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.N...
分类:
其他好文 时间:
2014-07-26 01:42:16
阅读次数:
263
http://acm.hdu.edu.cn/showproblem.php?pid=1244状态转移方程:dp[i][j]=max(dp[i][j-1],dp[i-1][j-a[i]]+sum[j]-sum[j-a[i]]);dp[i][j]为第i段第j个数。 1 #include 2 #incl....
分类:
其他好文 时间:
2014-07-26 01:10:36
阅读次数:
287
题目:如果采取暴力搜索,复杂度为O(n2),会超时解法1:构建Node类,存储输入的数据和它们的下标。用sort按升序排序(其中lambda可以写成一个返回值为bool类型的函数)。设置i和j,分别指向容器的头和尾。如果和大于target,尾向前移,如果和小于target,头向后移。直至找出和等于t...
分类:
其他好文 时间:
2014-07-26 00:31:46
阅读次数:
223
http://www.blogjava.net/fhtdy2004/archive/2009/07/05/285519.html线程同步:何时互斥锁不够,还需要条件变量?很显然,pthread中的条件变量与Java中的wait,notify类似假设有共享的资源sum,与之相关联的mutex 是loc...
分类:
编程语言 时间:
2014-07-26 00:21:16
阅读次数:
249
Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ...
分类:
其他好文 时间:
2014-07-25 14:13:21
阅读次数:
317