- 博客(19)
- 收藏
- 关注
原创 POJ-1789 Truck History 裸最小生成树
#include#include#include#include#include#include#include#includeusing namespace std;const int maxn = 2005;const int inf = 1<<30;int n;int map[maxn][maxn],dis[maxn];bool vis[maxn];string
2014-01-24 15:14:53 392
原创 取模快速幂
__int64 fun( int x ) { __int64 sum = 1,tmp = 26; while( x ){ if( x&1 ){ sum = sum * tmp; sum %= MOD; } tmp = (tmp*tmp)%MOD;
2014-01-24 14:47:03 507
原创 HDU-3461 Code Lock 并查集 + 二分求幂
题目链接题意是说有N个字母组成的密码锁, 如【wersdfj】, 每一位上的字母可以转动, w可转动变成x, z变成a。但是题目规定, 只能同时转动某个区间上的所有字母, 如【1,3】, 那么第1到第3个的所有字母要同时转动,那么【 wersdfj 】经过一次操作就变成 【 xfssdfj 】. 一共有M 个区间是可以操作的。 题目还规定:If a lock c
2014-01-24 14:42:12 550
原创 HDU-3172 Virtual Friends 并查集+map
题目链接#include#include#include#include#include#include#include#include#includeusing namespace std;const int maxn = 100050;const int inf = 1<<30;int n,m;int p[maxn],mark[maxn];mapmaps;in
2014-01-24 13:30:33 436
原创 POJ-3522 Slim Span 最小生成树最小边权差
题目大意:n个点m条边 用n-1条边连接n个点并边权差最小思路:枚举最小边 + Kruskal#include#include#include#include#include#include#include#includeusing namespace std;const int maxn = 105;const int inf = 1<<30;int n,m
2014-01-19 22:35:49 482
原创 HDU-3038 How Many Answers Are Wrong
题目链接#include #include #include using namespace std;#define maxn 200020int n,m;int p[maxn],weight[maxn]; //并查集祖先结点 并查集权值int find(int x){ if( p[x] == x ) return x; int t =
2014-01-19 12:08:36 346
原创 HDU-1272 小希的迷宫 并查集
题目链接#include "stdio.h"const int maxn = 100050;int p[maxn],rank[maxn];bool vis[maxn];int n,flag;int find( int x ){ return p[x] == x ? x:p[x] = find(p[x]);}void merge( int a,int
2014-01-19 12:01:48 413
原创 POJ-3164 Command Network 最小树形图 朱刘算法
朱刘算法参考之 http://blog.csdn.net/wsniyufang/article/details/6747392#include#include#include#includeusing namespace std;const int maxn = 115;#define type double const type inf = 1<<30;int n
2014-01-16 16:36:05 522
原创 POJ-2415 Hike on a Graph 搜索
题目连接题目大意:在一个完全图(每条边都有各自的颜色)中有3个piece,每个piece只能沿一条边移动(移动的条件为:这条边的颜色与另外两个piece间的边的颜色一样);问把三个piece移动到同一个点所需要的最小步数。BFS里的结束判断还是找个一个判断好点 出队再判断数据大时间废挺大QAQ血的教训#include#include#include#i
2014-01-15 16:01:43 509
原创 POJ - 1101 The Game DFS
H - The GameTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionOne morning, you wake up and think: "I am such a good programmer.
2014-01-14 18:07:55 457
原创 HDU-3912 Turn Right 简单搜索
D - Turn RightTime Limit:2000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionThis summer, ELT and his classmates went to Beijing for a training
2014-01-14 17:05:37 544
原创 POJ-1111 Image Perimeters 简单搜索
G - Image PerimetersTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionTechnicians in a pathology lab analyze digitized images of s
2014-01-14 15:33:00 457
原创 POJ-1915 Knight Moves 简单搜索
F - Knight MovesTime Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionBackgroundMr Somurolov, fabulous chess-gamer indeed, asserts t
2014-01-14 14:26:25 497
原创 HDU - 1226 超级密码
题目连接重点是余数判重 其他就是简单搜索问题但是有两个bug:1、M个整数可能有重复的。2、N可能为0。 int judge(node &a) { int tmp=0; int i; for(i=0;i<a.len;i++) { tmp=(tmp*c+a.base
2014-01-13 16:19:44 441
原创 HDU-1129 Channel Allocation
A - Channel AllocationTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionWhen a radio station is broadcasting over a very large are
2014-01-12 15:22:11 762
原创 HDU-4771 Stealing Harry Potter's Precious DFS + BFS
A - Channel AllocationTime Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionWhen a radio station is broadcasting over a very large are
2014-01-12 12:39:44 422
原创 概率DP总结 by kuangbin
http://www.cnblogs.com/kuangbin/archive/2012/10/02/2710606.html
2014-01-10 15:55:22 995
原创 POJ-3267 The Cow Lexicon 简单DP
题意就是给出一个主串,和一本字典,问最少在主串删除多少字母,可以使其匹配到字典的单词序列。PS:是匹配单词序列,而不是一个单词#include#include#include#includeusing namespace std;const int maxn = 605;int W,L;int dp[maxn],len[maxn];string str,word[m
2014-01-10 15:33:11 408
原创 FAFU-1395 翻牌 DP
学习陈新大神代码 #include#include#include#include#include#includeusing namespace std;const int maxn = 1050;int n;int dp[maxn*12],p[maxn*6]; //dp[i]bool cmp( int a,int b ){ return a > b;}
2014-01-06 15:28:06 460
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人