05 2013 档案
摘要:dp[i][j]=max(max(max(dp[i-1][j]+map[s[i]]['-'], d[i][j-1]+map['-'][ss[j]]),dp[i-1][j-1]+map[s[i]][ss[j]]),dp[i][j]);View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 int map[6][6]={ 5 0,0,0,0,0,0, 6 0,5,-1,-2,-1,-3, 7 0,-1,5,-3,-2,-4, 8 0,-2,-3
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1081一维最大字段和:dp [ i ] = max ( dp[ i-1 ] , 0 ) + a [ i ] ;如果是二维的话,可以变成一维的用map [ i ] [ j ] 表示第 i 行前 j 个元素的和,dp [ k ] [ i ] (l 表示j) 表示到第 k 行 第 i 列的最大值则dp [ k ] [ i ] = max ( map [ k ] [ i ] - map [ k ] [ j -1 ] , 0 ) , ( j <= i ) .View Code 1 #include<stdi
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2525WA了很多次,从网上档的代码,留着自己慢慢悟View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 5 6 int N, D, A, K, X; 7 // 保留两个信息,即当天克隆人已经生存的天数 8 // 以及正在培育中的人已经培育的天数 9 // 由于天数最多只有100天,所以我们可以使用数组来进行模拟 10 11 __int64 P[105], W[105]; // P表
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2522View Code 1 #include<stdio.h> 2 #include<string.h> 3 int mark[100002]; 4 void pow(int x) 5 { 6 int t; 7 mark[1]=1; 8 t=1; 9 while(t)10 {11 t=t*10;12 printf("%d",t/x);13 t=t%x;14 if(mark[t])//再次出现相同的余数,...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2491View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #define N 100008 4 struct cere 5 { 6 int x,y; 7 int mid,end; 8 }a[N]; 9 int cmp(const void *a,const void *b)10 {11 struct cere *c,*d;12 c=(struct cere *)a;13 d=(struct cere *)b;14 ...
阅读全文
摘要:View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #define M 999999999 5 #define N 2000000 6 int a[610],map[610][610]; 7 int b[610],c[610],g[N]; 8 int Min(int x,int y) 9 { 10 if(x>y) 11 return y; 12 else 13 return x; 14 } 15 void prim() 16 { 17 ...
阅读全文
摘要:http://poj.org/problem?id=1094思路: 题目的意思就是说每输入一个关系,进行一次拓扑排序,知道能够确定n个字母的顺序 或者是存在环。在编写程序时首先要判断是不是有环,如果有,返回0, 如果存在多种情况,标记flag2为-1,然后继续进行判断有没有环,如果没有,返回-1; 如果没没出现上述情况,则返回1。View Code 1 #include <stdio.h> 2 #include <string.h> 3 int n,m,j,i; 4 int map[100][100],q,d[100],t[100]; 5 int flag,flag1;
阅读全文