随笔分类 -
HDU
HDU 2066 一个人的旅行
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2066裸最短路,一开始又sb了,处理错复杂度TLE,囧View Code #include #include const int INF=1000000001;const int maxn=1001;int G[m...
阅读全文
HDU 1596 find the safest road
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1596最短路ps:0可以理解为那两个城市之间没有直接的通道,少看了这个条件错惨,在sx和zbw两位祖先的帮助下认清了这个问题#include #include using namespace std;const d...
阅读全文
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...
阅读全文
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...
阅读全文
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...
阅读全文
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
阅读全文
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
阅读全文
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,
阅读全文
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
阅读全文
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.
阅读全文
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,
阅读全文
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
阅读全文
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 *...
阅读全文
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...
阅读全文
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...
阅读全文
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; ...
阅读全文
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]; ...
阅读全文
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<=
阅读全文
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].
阅读全文
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;}
阅读全文
|