码迷,mamicode.com
首页 >  
搜索关键字:max    ( 23629个结果
hdu 4884 TIANKENG’s rice shop(模拟)
# include # include # include # include using namespace std; int max(int a,int b) { return a>b?a:b; } int main() { int T,n,t,k,m,i,hh,min,id,num,x; int last[1010];//最后一次开始炒饭的时间 int cot[1010];/...
分类:其他好文   时间:2014-07-30 14:45:53    阅读次数:164
hdu2066一个人的旅行
枚举所有相邻城市,作为起点,多次spfa,然后每次在想去的城市中找出spfa后的距离起点最短的花费时间 #include #include #include using namespace std; #define MAX 1005 #define INF 1<<30 int T,S,D; struct Edge{ int to,time,next; }edge[MAX*2...
分类:其他好文   时间:2014-07-30 12:19:03    阅读次数:215
MySQL server has gone away 问题的解决方法
场景:导入一个 sql 文件,但是 总是在执行几十句sql之后就失败了,打开失败日志 就一句 MySQL server has gone away 我使用了2个步骤,但是感觉是第2步成功的 1: 先看看 max_allowed_packet , 使用语法为 show global variables...
分类:数据库   时间:2014-07-30 12:02:43    阅读次数:273
0-1背包问题
最基础的背包问题:每种物品仅有一件,可以选择放或者不放! 动态转移方程:f[i, v] = max { f [i-1][v] , f [i-1] [j - c[i] ]+w[i] } ; // 不放第 i 件 // 如果放进去(但是要保证放进去前,剩余空间够大 ) 比较这两项的价值,我们会选择最大的...
分类:其他好文   时间:2014-07-30 11:31:03    阅读次数:151
防止变量超过上限的巧妙办法
int?n=0; int?max?=?100; //通常的做法(省略上下文) if(n>=max) { ????n?=?0; } n++; //巧妙的做法 n%=max n++
分类:其他好文   时间:2014-07-30 10:15:03    阅读次数:222
HDU 1718 Rank counting sort解法
本题是利用counting sort的思想去解题。 注意本题,好像利用直接排序,然后查找rank是会直接被判WA的,奇怪的判断系统。 因为分数值的范围是0到100,非常小,而student 号码又非常大,故此天然的需要利用counting sort的情况。 #include #include const int MAX_N = 101; int arr[MAX_N]; int...
分类:其他好文   时间:2014-07-30 10:06:33    阅读次数:214
动态内存
intcount=0;//定义数组长度printf("请输入数组长度:");scanf("%d",&count);int*p=malloc(sizeof(int)*count);for(inti=0;i<count;i++){*(p+i)=arc4random()%(count-1+1)+1;printf("%d",*(p+i));}printf("\n");intmax=0;for(inti=0;i<count;i++){if(max<*(p+i)){ma..
分类:其他好文   时间:2014-07-30 03:30:33    阅读次数:202
容易忽略的小程序比较大小,算法
刚刚从网上看到的#include<stdio.h>intmain(){inti=0;intmax=0;intn=5;intinput_data=0;for(i=0;i<n;i++){scanf("%d",&input_data); if(input_data>max) { max=input_data; }}printf("max=%d\n",max);return0;}忽略了输入值全负的情况
分类:其他好文   时间:2014-07-30 03:23:43    阅读次数:236
背包问题:0/1背包问题 普通背包问题(贪心算法只适用于普通背包问题)
//sj和vj分别为第j项物品的体积和价值,W是总体积限制。//V[i,j]表示从前i项{u1,u2,…,un}中取出来的装入体积为j的背包的物品的最大价值。第一种:0/1背包问题最大化,受限于1)若i=0或j=0,V[i,j] = 02)若j0且j>=si, V[i,j] = Max{V[i-1,...
分类:其他好文   时间:2014-07-30 00:54:02    阅读次数:265
HDU 1160 FatMouse's Speed DP题解
本题就先排序老鼠的重量,然后查找老鼠的速度的最长递增子序列,不过因为需要按原来的标号输出,故此需要使用struct把三个信息打包起来。 查找最长递增子序列使用动态规划法,基本的一维动态规划法了。 记录路径:只需要记录后继标号,就可以逐个输出了。 #include #include using namespace std; const int MAX_N = 1005;...
分类:其他好文   时间:2014-07-29 22:08:43    阅读次数:292
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!