本文版权归点A点C和博客园共有,欢迎转载,但必须保留此段声明,并给出原文连接,谢谢合作!!!

随笔分类 -  hdu

hdu4472-Count
摘要:CountTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1092Accepted Submission(s): 717Problem DescriptionProf. Tigris is the head of an archaeological team who is currently in charge of an excavation in a site of ancient relics.This site contains rel 阅读全文

posted @ 2013-11-09 21:52 点A点C 阅读(310) 评论(0) 推荐(0)

hdu1022Train Problem I(栈的模拟)
摘要:用到的一些栈的东西:<stack>类文件中的函数stack<int>p;定义一个int型的栈pp.push(x)向栈中压入一个元素xp.top()取栈顶元素的值p.pop()弹出栈顶元素p.empty()清空栈isEmpty()判断栈是否为空#include<stdio.h>#include<stack>using namespace std;int main(){ int n,i,j,b[200],k; char o1[100],o2[100]; stack<char>p; p.push('s');//提前在栈的底部 阅读全文

posted @ 2012-11-24 19:10 点A点C 阅读(215) 评论(0) 推荐(0)

hdu1398 Square Coins(母函数、完全背包)
摘要:#include<stdio.h>int t[301];int b[301];int main(){ int n,i,j,k; while(scanf("%d",&n)!=EOF&&n) { for(i=0;i<=n;i++) { t[i]=1; b[i]=0; } for(i=2;i<=17;i++) { for(j=0;j<=n;j++) { for(k=0;j+k<=n;k+=i*i) ... 阅读全文

posted @ 2012-11-22 18:56 点A点C 阅读(218) 评论(0) 推荐(0)

hdu1016Prime Ring Problem(经典DFS)
摘要:题目很简单就是输入一个数n,之后把1-n放入一个圆环中使每个数与它两边的任意一个数相加都是素数,把所有可能的排列情况输出出来。ps:刚开始练深搜,当时对那个输出所有的可能的情况那个递归迷糊了半天。代码:#include<stdio.h>#include<math.h>#include<string.h>int n;int temp;//记录已经有多少个节点有数int r[21];//记录每个节点的数的值bool vis[21];//记录每个节点是否存在数bool prime[40];//对40之内的数进行素数的判定,如果是素数则标记为1反之则标为0bool 阅读全文

posted @ 2012-11-15 20:19 点A点C 阅读(237) 评论(0) 推荐(0)

hdu1312 Red and Black(最基础的搜索题)
摘要:这个题就是找和'@'相连通的'.'的个数再加1。深搜和广搜都可以,只不过貌似广搜更省时间。我的是用广搜写的:View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<queue> 4 using namespace std; 5 char map[21][21]; 6 int h,w,sum; 7 struct node 8 { 9 int x;10 int y;11 };12 struct node start;13 void make_map()14 {15 阅读全文

posted @ 2012-11-10 16:19 点A点C 阅读(194) 评论(0) 推荐(0)

hdu 1789 Doing Homework again (贪心)
摘要:思路:把所有的的作业按分值从大到小排序,之后去从最大的那头开始取,在保证完成的情况下尽量靠后安排,如果它截止日期前的每一天都有任务了的话就把这一科的分数加到最后要扣的分中(比如:样例二中排序后应该是6,3,2对应的截止日期分别是1,1,3,所以第1天的时候完成6分的,当到3分的时候因为截至日期是1而且第1天也已经有任务了所以这一科他就无法完成)很久以前做的一个题了!!View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define N 1010 4 int flag[1010]; 5 int main() 6 { 阅读全文

posted @ 2012-11-10 16:12 点A点C 阅读(243) 评论(0) 推荐(0)

1004 Let the Balloon Rise(水题)
摘要:View Code 1 #include<stdio.h> 2 #include<string.h> 3 char s[1002][20]; 4 char ss[1002][20]; 5 int k[1002]; 6 int main() 7 { 8 int i,n,j,x,w; 9 while(scanf("%d",&n)!=EOF&&n)10 {11 scanf("%s",s[0]);12 getchar();13 w=0;14 strcpy(ss[0],s[0]);15 k[0]=1... 阅读全文

posted @ 2012-11-10 16:03 点A点C 阅读(162) 评论(0) 推荐(0)

hdu1029 Ignatius and the Princess IV(统计)
摘要:这个题很无语,先贴代码了! 1 #include<stdio.h> 2 #define N 9999//最小是9999,测试数据里最大的数就是9999 3 int main() 4 { 5 int a[N]={0},n,x,i; 6 while(scanf("%d",&n)!=EOF) 7 { 8 i=n; 9 while(n--) 10 { 11 scanf("%d",&x); 12 ... 阅读全文

posted @ 2012-11-04 19:52 点A点C 阅读(248) 评论(0) 推荐(0)

hdu1050 Moving Tables
摘要:题意:在一个长走廊里搬桌子,走廊的两侧都是房间,把桌子从一个房间搬到另外一个房间,走廊的宽度只能允许一个桌子通过,每次搬桌子需要10分钟(每一次允许再不交叉的走廊中同时搬桌子),问最少多长时间搬完!思路:因为每次搬的时间是一定的,所以可以看作是至少要搬多少次。而决定它最少搬多少次的因素就是有多少次搬桌子的过程中是存在线路的交叉的!所以可以把每一两个相对的房间之间的走廊所通过的次数记录下来(房间1和2之间的走廊用room[1]),找出所有部分通过最多的一个部分,它的通过次数就是在搬运过程中最大的交叉次数,也就是所需要的最少的搬运次数!View Code 1 #include<stdio.h 阅读全文

posted @ 2012-11-04 17:32 点A点C 阅读(1486) 评论(1) 推荐(0)

hdu3791 搜索二叉树 (最基本的树)
摘要:View Code 1 #include<stdio.h> 2 #include<string.h> 3 int tree[1050]; 4 int tree1[1050]; 5 char s[12]; 6 int main() 7 { 8 int t,i; 9 while(scanf("%d",&t),t)10 {11 scanf("%s",s);12 memset(tree,-1,sizeof(tree));13 for(i=0;s[i];i++)14 {15 int c=s[... 阅读全文

posted @ 2012-11-02 17:23 点A点C 阅读(323) 评论(0) 推荐(0)

hdu1072 Nightmare (BFS)
摘要:题目大意:给一个包含N*M个格子的迷宫,0代表墙,1代表通道,2代表入口,3代表出口,4代表地雷重置点,起始时地雷的爆炸时间是6秒,人每走一个格子需要1秒,问这个人最少多少秒可以走出迷宫,如果不能在爆炸前走出迷宫输出-1。思路:因为这题有个地雷重置点所以走过的路任然可以重复去走,所以在用bfs的时候对于已走过的路径不能标记。所以带出一个新的问题就是当两个地雷重置点之间可能会出现一直往复的走的现象,所以我们把只要走过的地雷重置点都标记为0(也就是说每个地雷重置点只用一次,因为多用并没有意义)。之后我们开始去广搜,直到找到出口!ps:思路来源于网路。思路来源代码: 1 #include<io 阅读全文

posted @ 2012-11-02 16:14 点A点C 阅读(212) 评论(0) 推荐(0)

hdu 2391 Filthy Rich
摘要:题目大意:在一个r*c的方格中行走,只能向下和向右走,每个格子内有一定的黄金,问能得到的最大黄金数。AC代码:View Code 1 #include<stdio.h> 2 #include<string.h> 3 int dp[1002][1002]; 4 int max(int a,int b) 5 { 6 if(a>b)return a; 7 else return b; 8 } 9 int main()10 {11 int t;12 scanf("%d",&t);13 int w=1;14 while(t--)15 {16 .. 阅读全文

posted @ 2012-10-25 16:56 点A点C 阅读(197) 评论(0) 推荐(0)

hdu2187 悼念512汶川大地震遇难同胞——老人是真饿了
摘要:直接排序,捡便宜的买!View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<algorithm> 5 using namespace std; 6 struct node 7 { 8 int p; 9 int h;10 };11 struct node mi[1001];12 int cmp(const void *a,const void *b)13 {14 return (*(node*)a).p>=(*(node*)b).p 阅读全文

posted @ 2012-10-06 19:03 点A点C 阅读(547) 评论(0) 推荐(0)

导航