2012年7月21日

【解题报告】【HODJ1017】【简单题】A Mathematical Curiosity

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=10171.判断整数的方法:除以某个整数,如果还是整数,则证明是整数2.Sample Input中里面包含了空格,但实际上没有3.注意结尾换行 1 #include<stdio.h> 2 int main() 3 { 4 int N,k,n,m,i,j,sum,t; 5 scanf("%d",&N); 6 for(k=1;k<=N;k++) 7 { 8 t=1; 9 while(scanf("%d%d",&n,&m)!= 阅读全文

posted @ 2012-07-21 18:59 coding封神 阅读(95) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2048】【错排】神、上帝以及老天爷

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2048 1 #include <stdio.h> 2 double a[22]={1}; 3 double b[22]={0,0,1}; 4 int main() 5 { 6 int i,m,n; 7 for(i=1;i<21;i++) 8 { 9 a[i]=i*a[i-1];10 }11 for(i=3;i<21;i++)12 b[i]=(i-1)*(b[i-1]+b[i-2]);13 scanf("%d",&n);1... 阅读全文

posted @ 2012-07-21 18:57 coding封神 阅读(127) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1789】【贪心算法】Doing Homework again

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 1 #include<stdio.h> 2 struct node{ 3 int x,y; 4 }; 5 int main() 6 { 7 struct node a[1001]; 8 int record[1001],flag,sum,i,j,t1,n,T,t2; 9 //freopen("1.txt","r",stdin);10 scanf("%d",&T);11 while(T--)12 {13 scanf 阅读全文

posted @ 2012-07-21 18:56 coding封神 阅读(160) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2037】【贪心算法】今年暑假不AC

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2037 1 #include<stdio.h> 2 struct node{ 3 int x,y; 4 }; 5 int main() 6 { 7 struct node a[101]; 8 int i,j,n,sum,q,y,w,t; 9 //freopen("1.txt","r",stdin);10 while(scanf("%d",&n)!=EOF&&n)11 {12 for(i=0;i<n; 阅读全文

posted @ 2012-07-21 18:55 coding封神 阅读(124) 评论(0) 推荐(0) 编辑

【解题报告】【HODJ1231】【最大子序列和】最大连续子序列

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1231 1 #include<stdio.h> 2 int main() 3 { 4 int n,i,j,k1,k2,sum,sumx; 5 int a[10000],leap1,leap2; 6 while(scanf("%d",&n)!=EOF&&n) 7 { 8 for(i=0;i<n;i++) 9 scanf("%d",&a[i]);10 leap1=0;11 leap2=1;12 ... 阅读全文

posted @ 2012-07-21 18:54 coding封神 阅读(133) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2159】【二维背包】FATE

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2159 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 //up 升级所需经验值 6 //n 怪兽种类 7 // volumn1 最大忍耐度 8 //volumn2 最多打怪数 9 //value[i] 打怪经验值 10 //cost1[i] 忍耐度的消耗11 //cost2[i] 打怪数的消耗12 //record[][] 二维背包13 int recor... 阅读全文

posted @ 2012-07-21 18:52 coding封神 阅读(142) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2191】【多重背包】悼念512汶川大地震遇难同胞——珍惜现在,感恩生活

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2191思路是将数量为n的物品按1 2 4 8 16.....分割成多个物品,然后按0/1背包的思路做,1 2 4 8...分别代替二进制中的一个位,可以通过加得到任何数,如13分为 1 2 4 6 1 #include<stdio.h> 2 #include<string.h> 3 #define MAX 510 4 #define max(a,b) (a>b?a:b) 5 int main() 6 { 7 int value[MAX],weight[MAX],reco 阅读全文

posted @ 2012-07-21 18:51 coding封神 阅读(123) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1114】【完全背包】Piggy-Bank

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114注:1.01背包使用的是逆序,完全背包使用的顺序。2.此题不是求最大,而是在满足背包全满的条件下,使之价值最小,也就是求最低下限。 1 #include<stdio.h> 2 #include<string.h> 3 #define MAX 501 4 #define INF 0x3f3f3f3f 5 #define min(a,b) (a>b?b:a) 6 int main() 7 { 8 long int weight[MAX],value[MAX],reco 阅读全文

posted @ 2012-07-21 18:49 coding封神 阅读(116) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1864】【01背包】最大报销额

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1864 1 #include<stdio.h> 2 int main() 3 { 4 double price,sum,a,value[31],record[31]; 5 int c,t,i,j,flag,n,sa,sb,sc; 6 char str; 7 //freopen("1.txt","r",stdin); 8 while(scanf("%lf%d",&price,&c)!=EOF&&c) 阅读全文

posted @ 2012-07-21 18:46 coding封神 阅读(140) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2955】【01背包】Robberies

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955 1 #include<stdio.h> 2 int main() 3 { 4 int t; 5 double value[105],P,gailv; 6 int volumn[105]; 7 double record[105*100]; 8 int V,i,n,j,price; 9 //freopen("1.txt","r",stdin);10 scanf("%d",&t);11 while(t--)12 {1 阅读全文

posted @ 2012-07-21 18:45 coding封神 阅读(109) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2602】【01背包】Bone Collector

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=26021.此题的约束条件volume是整形的。用三个数组,volume,value和record,分别记录体积,价值,和判断后的价值,record的下标代表空间,其值代表判断i个物品后各个空间的总价值。2.对于每一个物品,考虑每一种空间的情况,如第一个物品时,空间为10时,有两种情况,一是不取,二是取,然后将其值和剩下空间能得到的最大价值相加,选取两者中价值最大的。如如第一次判断时,物品1的volume是5,value是1,当V=10时,初始化时,record都置零,那么此时,record[10]= 阅读全文

posted @ 2012-07-21 18:42 coding封神 阅读(120) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2084】【动态规划数塔】数塔

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=20841.此题暴力解决会超时,需用动态规划,如果用递归的话,也回超时,所以需要在递归上改进一下。2.用两个数组,一个叫奇数组,标号为a[1][],一个叫偶数组,为a[0][];第一次是奇数组存储读入的数,偶数组存储操作结果,第二次是偶数组存取读入数,奇数组存储操作结果,这样循环。 1 #include<Stdio.h> 2 #include<string.h> 3 #define MAX 101 4 #define max(a,b) (a>b?a:b) 5 int ma 阅读全文

posted @ 2012-07-21 18:39 coding封神 阅读(129) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1010】【DFS矩阵地图】Tempter of the Bone

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1010 1 #include<stdio.h> 2 #include<string.h> 3 #include<math.h> 4 int map[10][10]; 5 int n,m,t; 6 int si,sj,ei,ej; 7 int bx[4]={1,0,-1,0},by[4]={0,1,0,-1}; 8 int result; 9 void print();10 void read_operation(int i,int j,char c);11 voi 阅读全文

posted @ 2012-07-21 18:36 coding封神 阅读(116) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1016】【DFS素数环】Prime Ring Problem

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1016注意:行末没空格,每次测试数据都要多输出一行 1 #include<stdio.h> 2 #include<string.h> 3 int time;//计数器 4 int n;//数字规模 5 int ring[22];//记录环的内容 6 int record[22];//记录数字是否用过 7 int prime[40];//素数表 8 void init();//初始化函数 9 void makePrime();//用筛选法构造素数表10 void play(in 阅读全文

posted @ 2012-07-21 18:34 coding封神 阅读(118) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1233】【最小生成树】还是畅通工程

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1233prim最小生成树 1 #include<stdio.h> 2 #include<string.h> 3 #define INF 0x3f3f3f3f 4 #define min(a,b) (a>b?b:a) 5 6 long int map[101][101]; 7 long int n,m; 8 int set[101]; 9 long int sum;10 void prim_init()11 {12 int i,a,b,c;13 memset(map,INF,siz 阅读全文

posted @ 2012-07-21 18:32 coding封神 阅读(116) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1102】【最小生成树】Constructing Roads

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102prim最小生成树 1 #include<stdio.h> 2 #include<String.h> 3 #define INF 0x3f3f3f3f 4 int map[105][105]; 5 int set[105]; 6 int sum; 7 int n; 8 void prim(){ 9 int t=INF,tt,i,j;10 for(i=1;i<=n;i++){11 if(set[i])12 for(j=1;j<=n;j++... 阅读全文

posted @ 2012-07-21 18:30 coding封神 阅读(140) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2544】【Bellman-Ford最短路】最短路

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 1 #include<stdio.h> 2 #include<string.h> 3 #define INF 0x3f3f3f3f 4 struct node{ 5 int u; 6 int v; 7 int weight; 8 }; 9 struct node map[10001];10 int record[101];11 int n,m;12 13 void Bellman_init()14 {15 int i;16 for(i=0;i<2*m;... 阅读全文

posted @ 2012-07-21 18:27 coding封神 阅读(109) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2544】【Dijkstra最短路】最短路

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 1 #include<stdio.h> 2 #include<string.h> 3 #define INF 0x3f3f3f3f 4 #define min(a,b) (a>b?b:a) 5 6 int map[101][101]; 7 int n,m; 8 int record[101]; 9 int set[101];10 11 void Dijkstra_init()12 {13 int a,b,c,i;14 memset(map,INF,sizeof( 阅读全文

posted @ 2012-07-21 18:25 coding封神 阅读(118) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ2544】【Floyd最短路】最短路

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 1 #include<stdio.h> 2 #include<string.h> 3 #define INF 0x3f3f3f3f 4 #define min(a,b) (a>b?b:a) 5 int map[101][101]; 6 int main() 7 { 8 int n,m,i,j,k,a,b,c; 9 //freopen("1.txt","r",stdin);10 while(scanf("%d%d& 阅读全文

posted @ 2012-07-21 18:23 coding封神 阅读(146) 评论(0) 推荐(0) 编辑

【解题报告】【HDOJ1874】【Floyd最短路】畅通工程续

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1874注意重边和环:1.重边在读取的时候用min选取最小的2.环则在输出时进行判断 1 #include<stdio.h> 2 #include<string.h> 3 #define INF 0x3f3f3f3f 4 #define min(a,b) (a>b?b:a) 5 long int map[201][201]; 6 int main() 7 { 8 9 long int n,m,a,b,i,j,k,c; 10 //freopen("1.txt&qu 阅读全文

posted @ 2012-07-21 18:21 coding封神 阅读(121) 评论(0) 推荐(0) 编辑

导航