随笔分类 -  2012-1000系列

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 13 下一页

 
HDU 2112 HDU Today
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2112把地名和数字对应一下,就变成模板题了#include #include using namespace std;const int INF=10000000;const int maxn=101;int ni... 阅读全文
posted @ 2012-05-13 12:45 LegendaryAC 阅读(321) 评论(0) 推荐(0)
HDU 1874 畅通工程续
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1874第一次知道有个东西叫重边。。。囧View Code #include #include using namespace std;const int INF=1000000000;int map[210][21... 阅读全文
posted @ 2012-05-13 03:15 LegendaryAC 阅读(155) 评论(0) 推荐(0)
HDU 2544 最短路
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2544在TCO又一次0之后。。。突然会写最短路了,ORZView Code #include #include using namespace std;const int INF=100000000;int map... 阅读全文
posted @ 2012-05-13 02:59 LegendaryAC 阅读(172) 评论(0) 推荐(0)
HDU 1541 Stars
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1541画星星,注意要把所有点向右平移一位,否则update会死循环(在(0,0))ps:数组一定要开够啊啊啊View Code #include <stdio.h>#include <string.h>const int maxn1=15001;const int maxn2=32001;int n;int tree[maxn2],ans[maxn1];int lowbit(int i){ return i&(-i);}void update(int i,int val){ w 阅读全文
posted @ 2012-05-11 19:23 LegendaryAC 阅读(152) 评论(0) 推荐(0)
HDU 1678 Shopaholic
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1678继续是STL的堆,这道题最小堆最大堆均可,随手写一个就ok。刚开始题意理解有问题,各种wa,郁闷得要死。从最小堆来看,三个一组最小的加到答案里。如果元素总数不能被3整除,就先把堆顶元素出堆,直到能被3整除为止。View Code #include <iostream>#include <queue>#include <algorithm>using namespace std;int main(){ int t,n,p; int ans; priority_queue 阅读全文
posted @ 2012-05-11 12:06 LegendaryAC 阅读(237) 评论(0) 推荐(0)
HDU 4006 The kth great number
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4006第一反应是线段树,不过发现k是固定的。用STL的优先队列,很爽。http://blog.chinaunix.net/space.php?uid=533684&do=blog&cuid=2615612我从上面的博客学到很多STL优先队列的知识,ORZ一个View Code #include <iostream>#include <vector>#include <queue>using namespace std;int main(){ int n,k, 阅读全文
posted @ 2012-05-11 00:57 LegendaryAC 阅读(206) 评论(0) 推荐(0)
HDU 4079 Happy Telephones
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4079比大小的题。。。没用条件给一堆。。。View Code #include <iostream>#include <map>#include <string>#include <algorithm>using namespace std;typedef struct L{ int start,during;}L;L phone[11000];int main(){ int n,m,i,j; int start,during; int ans; while(s 阅读全文
posted @ 2012-05-10 18:05 LegendaryAC 阅读(257) 评论(0) 推荐(0)
HDU 1027 Ignatius and the Princess II
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1027求数列n的第m个排列,STL中next_permutation的应用。相对应的还有prev_permutation。View Code #include #include #include #include using namespace std;int main(){ int n,m,i; int s[1100]; while(~scanf("%d%d",&n,&m)) { for(i=1;iusing namespace std ;int n,m ;int vi. 阅读全文
posted @ 2012-05-10 17:08 LegendaryAC 阅读(198) 评论(0) 推荐(0)
HDU 1263 水果
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1263STL中map的练习View Code #include <iostream>#include <map>#include <string>using namespace std;int main(){ int n,m,k,i; int f=0; scanf("%d",&n); while(n--) { if(!f)f++; else putchar('\n'); map <string ,map<string, 阅读全文
posted @ 2012-05-10 16:35 LegendaryAC 阅读(264) 评论(0) 推荐(0)
HDU 1075 What Are You Talking About
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1075趁着HDOJ活了赶快交一个、、、刚开始学习STL的应用,这个代码学习自sx老祖。。。View Code #include <stdio.h> #include <iostream> #include <string> #include <map>using namespace std; int main(){ int i; char str[3001]; map <string,string> M; string str1,str2; cin 阅读全文
posted @ 2012-05-10 12:46 LegendaryAC 阅读(235) 评论(0) 推荐(0)
HDU 1671 Phone List
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1671依旧是Trie树,和上一题差不太多View Code #include #include #include const int MAX=10; typedef struct Trie{ Trie *... 阅读全文
posted @ 2012-05-09 02:14 LegendaryAC 阅读(218) 评论(0) 推荐(0)
HDU 1251 统计难题
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1251第一道Trie树,感觉有点厉害View Code #include #include #include const int MAX=26; typedef struct Trie{ Trie *ne... 阅读全文
posted @ 2012-05-09 01:53 LegendaryAC 阅读(302) 评论(0) 推荐(0)
HDU 1102 Constructing Roads
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1102最简单的最小生成树View Code #include #include #include int p[110];int cnt,n; typedef struct L{ int a,b,d; }L... 阅读全文
posted @ 2012-05-08 11:34 LegendaryAC 阅读(197) 评论(0) 推荐(0)
HDU 1162 Eddy's picture
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1162最简单的最小生成树。。。View Code #include #include #include int p[110];int cnt,n; typedef struct L{ int a,b; ... 阅读全文
posted @ 2012-05-07 23:37 LegendaryAC 阅读(190) 评论(0) 推荐(0)
HDU 1301 Jungle Roads
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1301最简单的最小生成树View Code #include #include int p[30];int cnt,n; typedef struct L{ int a,b,d;}L;L r[1000]; ... 阅读全文
posted @ 2012-05-07 22:43 LegendaryAC 阅读(186) 评论(0) 推荐(0)
HDU 1166 敌兵布阵(2)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1166老题新做,树状数组,比线段树省了300k内存View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>const int maxn=51000;int s[maxn];int nCase=1,n;int lowbit(int i){return i&(-i);} void update(int i,int val){ while(i<= 阅读全文
posted @ 2012-05-07 12:36 LegendaryAC 阅读(164) 评论(0) 推荐(0)
HDU 1992 Tiling a Grid With Dominoes
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1992hdu上很多这种砖块问题,废话少说,下面开始分析。高度是固定的,只用考虑宽度带来的影响。少一列,是dp[1]*dp[i-1]=dp[i-1]少两列,是dp[2]*dp[i-2]=5*dp[i-2],但是其中一种情况与少一列的重复,所以只有4*dp[i-2]再往后少奇数列,都只有2*dp[i](考虑可能情况并且不与前两种情况产生重复)再往后少偶数列,都只有3*dp[i](考虑可能情况并且不与前两种情况产生重复)综上分析,dp[i]=dp[i-1]+4*dp[i-2]+2*(dp[i-3]+dp[i-5]. 阅读全文
posted @ 2012-05-02 12:44 LegendaryAC 阅读(653) 评论(0) 推荐(0)
HDU 1060 Leftmost Digit
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1060脑筋急转弯。View Code #include <stdio.h>#include <math.h> int main(){ int t; double n; scanf("%d",&t); while(t--) { scanf("%lf",&n); printf("%d\n",(int)pow(10.0,n*log10(n)-(__int64)(n*log10(n)))); } return 0;} 阅读全文
posted @ 2012-05-01 14:25 LegendaryAC 阅读(132) 评论(0) 推荐(0)
HDU 4217 Data Structure?
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4217经典的线段树问题,找第k小数。注意sum用__int64View Code #include <stdio.h>#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=300000;int tree[maxn<<2];int temp;void build(int l,int r,int rt){ tree[rt]=r-l+1; if(l==r) return; int m=(l+r)& 阅读全文
posted @ 2012-04-29 22:14 LegendaryAC 阅读(340) 评论(0) 推荐(0)
HDU 2140 Michael Scofield's letter
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2140按题意翻译字符串View Code #include <stdio.h>#include <string.h>int main(){ char tab[10][2]={{'b',' '},{'q',','},{'t','!'},{'m','l'},{'i','e'},{'c','a'},{& 阅读全文
posted @ 2012-04-26 18:09 LegendaryAC 阅读(260) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 13 下一页