- 博客(20)
- 资源 (25)
- 收藏
- 关注
原创 hdu 3183 A Magic Lamp
http://acm.hdu.edu.cn/showproblem.php?pid=3183题意:从一个数里删除n个数字,使其最小分析:只需判断第i个数是否大于第i+1个数,实则删掉,否则继续寻找;注意0的存在,只要第二位数是0,直接删除第一个数即可,因为数的位数减少了#include#include#include#include#includeusing namespac
2013-07-30 20:08:02 528
原创 hdu 4070 Phage War
http://acm.hdu.edu.cn/showproblem.php?pid=4070题意:一个噬菌体周围有编号1~n个细胞,每一秒钟这个噬菌体就产生一个新的噬菌体,想要感染细胞需要:1)Di个噬菌体 2)Ti秒的到达时间,问最少需要多少时间可以使所有的细胞都被感染?分析:先感染需要到达时间最长的细胞,利用剩下时间繁殖噬菌体,然后更新最长时间#include#include#
2013-07-30 16:05:15 664
原创 【DFS】hdu 1518 Square
http://acm.hdu.edu.cn/showproblem.php?pid=1518#include#includeusing namespace std;const int NM=22;int a[NM],vis[NM],m,flag,tol;void DFS(int ans,int sum,int k){ int i; if(sum>tol) return;
2013-07-28 21:08:26 585
原创 hdu 2531 Catch him(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=2531分析:没啥说的,只是把防守队员整体当成一个点即可#include#include#includeusing namespace std;const int NM=105;char str[NM][NM];int vis[NM][NM],n,m;int a[4][2]={-1,0,1,
2013-07-28 17:51:41 687
原创 hdu 3316 Mine sweeping(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=3316分析:当遇到k=0时电脑会自动触发周围的8个方向点,8个方向中有地雷则不会点击该点,其余继续搜寻#include#include#include#includeusing namespace std;const int NM=105;char str[NM][NM];int a[8]
2013-07-27 23:14:49 765
原创 hdu 1239 Calling Extraterrestrial Intelligence Again
http://acm.hdu.edu.cn/showproblem.php?pid=1239分析:范围2~50000->10000,居然可以暴力成功,哎#include#include#includeusing namespace std;const int NM=10005;int pi[NM/2],a[NM];int main(){ int i,j,k,ans,m,
2013-07-26 22:01:33 447
原创 hdu 2612 Find a way(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=2612分析:两个好基友在固定地点见面,分别对这两人BFS,注意要预先处理步数#include#include#includeusing namespace std;const int NM=205;const int MAX=0xfffff;char str[NM][NM];int a[4
2013-07-26 20:30:39 550
原创 hdu1238 Substrings
http://acm.hdu.edu.cn/showproblem.php?pid=1238分析:枚举+STL#include#include#include#include#includeusing namespace std;const int NM=105;string str[NM];bool comp(string A,string B){ if(A.si
2013-07-25 21:33:25 570
原创 hdu 1240 Asteroids!
http://acm.hdu.edu.cn/showproblem.php?pid=1240分析:三维数组,同二维相同,同类型:hdu 1253 胜利大逃亡#include#include#includeusing namespace std;const int NM=15;int a[6][3]={{-1,0,0},{1,0,0},{0,-1,0},{0,1,0},{0,
2013-07-25 20:20:24 545
原创 hdu 1597 find the nth digit
http://acm.hdu.edu.cn/showproblem.php?pid=1597法一:分析:由题意知,设n在Si序列,则:i*(i-1)解二元一次方程:i^2+i-2*n=0,即:i=(-1+sqrt(1+8*n))/2#include#include#includeusing namespace std;int main(){ __int64 T,
2013-07-25 18:29:34 594
原创 hdu 1445 Ride to School
http://acm.hdu.edu.cn/showproblem.php?pid=1445分析:原先把问题想麻烦了,其实只要理清思路就会发现,无论自己的车速会怎么变,最后一定会和一个人同时到达,那么计算这个人的到达时间即可其中,时间为负数的不用考虑,要么你追不上,要么他追不上你#include#include#include#includeusing namespace st
2013-07-24 23:14:47 697
原创 hdu 4296 Buildings(外一篇:hdu 4310 Hero)
http://acm.hdu.edu.cn/showproblem.php?pid=42分析:条件:A.w+A.s具体分析:http://blog.csdn.net/acm_ted/article/details/79849351) a=sum-si;b=sum+wi-sj; 交换两个板的位置2)b'=sum-sj;a'=sum+wj-s
2013-07-23 22:01:14 551
原创 hdu 4550 卡片游戏
http://acm.hdu.edu.cn/showproblem.php?pid=4550分析:就是前导可恶的0,然后利用字符串,大于序列第一个数的放右边,反之放左边(#include#include#include#includeusing namespace std;int main(){ string str,card; char t; int T,i,j,len
2013-07-23 20:03:28 643
原创 【字典树】hdu 2846 Repository
http://acm.hdu.edu.cn/showproblem.php?pid=2846分析:字典树,注意保存每一个子串#include#include#includeusing namespace std;const int NM=10005;char str2[22];struct Node{ Node *next[26]; //代表该点的26个指针 in
2013-07-21 01:07:19 626
原创 【字典树】hdu 1671 Phone List
http://acm.hdu.edu.cn/showproblem.php?pid=1671分析:字典树#include#include#includeusing namespace std;const int NM=10005;char str[NM][15];int flag;struct Node{ Node *next[10]; int id; Node()
2013-07-20 23:27:59 721
原创 hdu 2102 A计划
http://acm.hdu.edu.cn/showproblem.php?pid=2102分析:遇到‘#’就跳到另外一层,本来想到两层相同位置同时为’#‘会发生冲突,没想到还是脑抽了认为已经考虑到这种情况了,还狂找bug,看来还是不够细心和自信,努力之#include#include#includeusing namespace std;const int NM=11;cha
2013-07-19 23:32:26 567
原创 hdu 1175 连连看(外一篇)
http://acm.hdu.edu.cn/showproblem.php?pid=1175分析:因为转弯次数的限制,用一直走到底的方法,其他各种方法变换搜索方向顺序均不能通过,是错误的#include#include#includeusing namespace std;const int NM=1005;struct Node{ int x,y,turn;};int
2013-07-17 13:08:35 530
原创 【DFS】hdu 1045 Fire Net
http://acm.hdu.edu.cn/showproblem.php?pid=1045分析:从第一个点到最后一个点依此暴搜#include #include #include using namespace std;const int NM=10;char str[NM][NM];bool vis[NM][NM];int mmax,num,n;bool
2013-07-17 10:47:15 592
原创 hdu 1051 Wooden Sticks
分析:排序后,从小找到大,注意保存第一个不满足条件的stick,作为第二次查找的开始#include#includeusing namespace std;const int NM=5005;struct Stick{ int x,y;}st[NM];bool comp(struct Stick A,struct Stick B){ if(A.x<B.x) retur
2013-07-13 11:14:48 506
原创 【DFS】hdu 2553 N皇后问题
#include#includeint sum,n,hang[15],xie1[25],xie2[25];void DFS(int i){ int j; if(i>n) sum++; else {for(j=1;j{if(!hang[j]&&!xie1[i+j]&&!xie2[n-i+1+j]) //列、对角线{hang
2013-07-03 18:23:04 724
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人