自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

yueqiq

仗义每多屠狗辈,负心多是读书人

  • 博客(207)
  • 收藏
  • 关注

转载 怎样成为一个ACMer

Bye-Bye..........给自己来个计划,记录一下历程....,黑色是还没学的,红的是学了的,蓝色是正在学习的.......一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. (5)构造法.(poj3295) (6)模拟法.(poj1068,poj

2012-06-07 09:22:58 982

原创 贴一份宏定义 防止丢失

#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define Si set#define

2012-06-06 09:14:56 427

转载 ACM历程

首先,我想说的就是,我是一个很普通的ACMer,高中没有参加过任何计算机和数学竞赛的经历,也没有ben那样过人的天资,努力至今也未能取得什么成绩,我之所以写下这篇文章,只是希望给刚进大学或者刚进ACM队的同学一点小小的帮助,希望你们可以少走一些弯路,更希望你们可以帮助华理取得我没能取得的辉煌。(1).起步阶段我是从大二开始接触ACM的,要说基础的话就是大一的C语言课程了,语言方面的基础

2012-06-01 13:36:00 1366

原创 vijos P1002 过河

刚开始没看到数据为 10^9 考虑 f[i] 为跳跃到i点所用的最少石子数,那么 f[i] = min(f[i-j]) + stone[i]   s然后就只能问度娘了,看了之后才发现其实和省赛的第二题差不多,如果两个石子M,N之间的距离很大的话,那么M,N之间最优的选择就是先最大距离的跳,当位置到N小于一个值的时候,再用dp来做,但是这个值到底是多少搜了好长时间也没有找到一个很确定的解释,最后选了

2013-01-20 19:11:09 1342

原创 hdu1588 Gauss Fibonacci

其实就是一个矩阵加上等比数列求和的问题,在因为b等于0的问题上卡住了,最后看了人家的解法重新构造了乘数矩阵code:#include #include #include #include #include #include #define LL long longusing namespace std;LL k,b,n,M;struct Matrix{ L

2012-12-13 18:10:11 447

原创 hdu2971 Tower

这题太狠了 ,TLE的我难受,整整做了一天。。借用别人的图片,就是这样构造矩阵。。。  其中 X = 2 * a2 , Y= -1;code:#include #include #include #define LL __int64using namespace std;LL a2,n,M;struct Matrix{ LL mat[5][5];

2012-12-13 18:07:44 822

原创 hdu2276 Kiki & Little Kiki 2

一看到开关灯问题,觉得应该是和矩阵有关系的,于是开始向矩阵上靠,发现第i个灯的下一次变化为 (i-1 + i)&1; 这样就可以构造矩阵了,很高兴没有trickcode:#include #include #include #include #include using namespace std;const int MAXN = 101;int n,m;ch

2012-11-15 19:22:54 321

原创 hdu2254 奥运

不明白可以去看Matrix大神的矩阵的十种应用去code:#include #include #include using namespace std;const int MAXN = 31;int city_num,city[MAXN];struct Mat{ int mat[MAXN][MAXN];}A,E;Mat operator+ (Mat a,Mat

2012-11-13 22:04:49 605

原创 hdu1850 Being a Good Boy in Spring Festival

Nim博弈问题,因为Nim博弈第一步要转化至必败态设    s=a1 ^ a2 ^ a3 ^ a4 ^ ...... an,那么只需要把 ak 换为 ak^s 即可,当然 前者必须要大因为 s=a1 ^ a2 ^ a3 ^ a4 ^ ak ^ s ^ .......an=a1^a2^a3^......an ^ s = s^s=0; 所以转为了必败态code:#include #i

2012-11-12 16:26:07 386

原创 Hdu1847 Good Luck in CET-4 Everybody!

笨方法打了sg值表,A了之后把Sg值打印出来一看,发现自己NC了,sg值只有0 ,1,2..................code:#include #include #include #include #include using namespace std;int sg[1001];int num[]={10,1,2,4,8,16,32,64,128,256,512

2012-11-12 15:28:08 513

原创 Hdu1846 Brave Game && Hdu2188 悼念512汶川大地震遇难同胞——选拔志愿者

基本的巴什博弈问题。1846 code:#include using namespace std;int n,m;int main(){ int cas; cin>>cas; while(cas--) { cin>>n>>m; if(n%(m+1)) cout<<"first"<<endl;

2012-11-07 18:37:32 459

原创 hdu1498 50 years, 50 colors

很简单的求最小点覆盖、code:#include #include #include #include using namespace std;const int MAXN = 110;int n,k;set col;set::iterator it;int ans[MAXN],cnt;bool graph[MAXN][MAXN];bool vis[MAXN];

2012-11-06 18:09:29 423

原创 hdu1150 Machine Schedule

将A和B分为2分图的两边,对于每个工作(i,x,y),就在两个点上连一条边,这条边就是工作,这样问题就转化成了用最少的点覆盖所有的边,即二分图的最小点覆盖。code:#include#include#includeusing namespace std;const int MAXN = 110;int n,m,k;bool graph[MAXN][MAXN];bool

2012-11-06 12:16:33 335

原创 hdu1608 Girls and Boys

二分图的最大独立点集,在构图的时候因为复制了一遍,所以求出来的最大匹配其实是两倍。code:#include#include#includeusing namespace std;const int MAXN = 1010;int n;bool graph[MAXN][MAXN];bool vis[MAXN];int link[MAXN];int find(int

2012-11-06 11:16:22 440

原创 Hdu1507 Uncle Tom's Inherited Land*

这个题郁闷了。。。卡了好长时间,不过还好过了。将不相邻的点分为一组,也就是横纵坐标相加为奇数的为一组,另外为一组,然后相邻的在两组中间连一条线,最后求最大匹配code:#include#include#includeusing namespace std;const int dx[]={-1,0,1,0};const int dy[]={0,-1,0,1};struct

2012-11-05 21:48:12 356

原创 Hdu1151 Air Raid

求最小路径覆盖Orzcode:#include#include#includeusing namespace std;int n,m,link[125];bool map[125][125],vis[125];bool find(int x){ int y; for(y=1;y<=n;y++) { if(map[x][y] && !

2012-11-05 14:09:22 421

原创 hdu3364 Lanterns

典型的高斯消元解开关灯问题。code:#include#include#includeusing namespace std;bool ctr[55][55],fuc[55][55];int equ,var;__int64 Guass(){ int row=0,col=0; for( int i,j; row<equ && col<var; row++,c

2012-11-05 12:35:33 666

原创 Hdu3584 Cube

code:#include #include #include using namespace std;int n,a[105][105][105];int lowbit(int x){ return x&(-x);}void update(int x,int y,int z){ int i,j,k; for(i=x;i<=n;i+=lowbit(i

2012-11-04 11:06:44 581

原创 HDU1053 Entropy

哈夫曼水题,就是题目爆长,涨英文了。code:#include #include #include using namespace std;char buf[300];multiset s;int n,cnt[151];//采用2进制的哈夫曼,clen进制数int huffman(char str[],int clen){ s.clear(); mems

2012-11-03 21:49:12 420

原创 hdu2874 Connections between cities

LCA问题,看了一天关于LCA问题,包括在线算法和离线算法,感冒发烧头疼,反正是看的挺难受的,其中包括在线算法,即 LCA转化为RMQ模型,还有离线算法,即tarjan,终于下定耐着性子把tarjan写完了,中间各种细节,想想都头疼,还好AC了,不然真没劲改下去了code:#include #include using namespace std;const int MAXN

2012-11-03 17:07:42 429

原创 hdu3231 Box Relations

直接抄代码了,因为实在是不知道怎么做啊,要转换成关系top,自己打死也想不到啊。。code:#include #include using namespace std;const int MAXN = 2010 ;struct node{ int to,next;}relations[100010];int n,cnt,adj[4][MAXN];int in

2012-11-02 13:02:58 462

原创 hdu2838 Cow Sorting

其实刚开始一看到这道题就想到了逆序对数,用归并或者树状数组来搞,不过加上了一个权值,顿时头就大了。。。。不知道该怎么换了。。。,后来发现读题真的很重要,题目给的数的范围是1-n之间的,而且没有重复。这样写法就变得很简单,而且在线了code:#include #define LL __int64using namespace std;const int MAXN = 100010 ;

2012-11-02 10:50:19 496

原创 hdu1075 What Are You Talking About

用map做的,很简单code:#include #include #include #include using namespace std;map dict;map::iterator it;char tmp1[25],tmp2[25],word[25];char sent[3030];int main(){ //freopen("output.txt"

2012-11-01 10:25:31 395

原创 hdu1028 Ignatius and the Princess III

智商的确是太拙计了,以前看过整数划分问题,现在还是不会做,设函数F(n,m)为整数n的划分中最大的整数是m,1.如果n等于1或者m等于1,肯定只有一种划分,即全是1的划分2.如果n等于m,肯定会出现一种划分,即一个数n,然后剩下的划分就是 F(n,m-1);3.如果n4.对于剩下的一般情况,第一种情况,n被划分为 m+m1+m2+m3....... ,其中m是最大的,那么剩下的

2012-10-17 10:55:34 275

原创 hdu1299 Diophantus of Alexandria

这题还是比较水的,因为稍微一整理就可以转化为求n的平方的因子个数的一半+1,因为n的平方的因子个数必定为奇数个;可怜TLE,MLE了若干次,竟然把素数表打到了10^9次方,真是智商拙计。code#include #include #define LL __int64using namespace std;const int MAXN = 40010;LL p

2012-10-10 10:54:32 353

原创 hdu3307 Description has only two Sentences

刚开始花了很长时间化简,求出x^k mod a0=1来却不知道怎么去求解。。。。看了解题报告,套用欧拉函数,因为 x^φ(a0) mod a0 =1,所以除了无解的情况,最大的解也不会超过φ(a0),然后比较φ(a0)的因子里,找一个最小的即可。对于无解的情况,即 Gcd(x,a0)!=1 ,假设存在共同因子m,那么x=x' * m,a0=a0' * m;则 (x' * m)^k - t*

2012-10-08 15:19:55 486

原创 关于欧拉函数的两种求法

第一种:LL Eular(LL n){ LL fac,ans=1; for(fac=2;fac*fac<=n;fac++) { if(n%fac==0) { n/=fac; ans*=fac-1; while(n%fac==0) {

2012-10-08 09:04:35 988

原创 hdu4121 xiangqi

挺恶心的模拟,卡了好长时间。。code:#include #include #include #include using namespace std;const int MAXN = 1005;const int dx[]={1,0,-1,0};const int dy[]={0,1,0,-1};char map[15][15];int n,bi,bj;struct

2012-10-08 07:32:57 447

原创 usaco Contact

暴力code:/*ID: yueqiPROG: contactLANG: C++*/#include #include #include #include #include #include #define LL __int64using namespace std;bool cmp(const pair &a,const pair &b){ if (a.fir

2012-09-27 20:36:14 695

原创 hdu4882 Coder

基本上算是抄的代码。。。。线段树,维护一个sum数组,sum数组存的是当前区间段以第1-5个数为起点的间隔为5的数的总和离线化处理也是以前从没有见过的code:#include #include #include #include #define LL __int64using namespace std;const int MAXN = 110005;struct

2012-09-27 19:41:36 342

原创 hdu1800 flying to the mass

又被水题虐了。。。。。。给你一堆士兵的等级,等级高的的士兵可以当等级小的士兵的师傅,一个士兵最多一个师傅(可以没有),一个师傅最多1个徒弟(可以没有),如果是师徒关系,可以用一把扫帚练习技能,问你如果全部士兵都用过扫帚练习时最小需要的扫帚数量。刚开始打算直接贪心的。。复杂度太高,tle了,,然后百度才发现所求的竟然就是出现最多的那一个数,即最长平台.用map做其实爆简单。。。code:#i

2012-09-25 17:58:39 385

原创 hdu1509 Windows Message Queue

优先队列水题,真心不懂那个code:#include #include #include using namespace std;struct Win{ char name[50]; int id,val,parameter; friend bool operator < (Win a,Win b) { if(a.val==b.v

2012-09-24 16:06:11 389

原创 hdu3038 How Many Answers Are Wrong

并查集真心高深,偏移量的问题以及路径压缩中的更新顺序问题真心把我搞迷糊了。。。。决定先不看并查集了。。。。code:#include #include using namespace std;class UFS{ static const int MAXN = 200001;public: int father[MAXN]; int rank[MAXN]

2012-09-24 15:02:17 383

原创 hdu3635 Dragon Balls

智商拙计啊,这题看了解题报告都不是很懂,郁闷。。。。。考虑了很长时间,才明白每个根结点最多只能移动一次,所以我们的目的就是把这一次push到各个子节点上就可以了,因为路径压缩的缘故,除了这次操作之外,所有的结点都挂在根节点上,完全水题一枚,被暴虐啊code:#include #include using namespace std;const int MAXN =

2012-09-24 13:18:40 307

原创 poj1281 棋盘游戏

这题应该算是一道比较简单的二分图问题,可是我压根还是没想到二分图,一看解题报告说用二分图,再一琢磨就明白了。。。。就是求二分图的最大匹配和关键匹配code:#include #include using namespace std;int n,m,k;int link[101];bool graph[101][101],vis[101];struct pos{ i

2012-09-23 22:41:38 622 1

原创 hdu1573 X问题

今天一早晨都花在这题上了,昨天晚上看了一晚上终于把数论回忆了一下思路:解模不互质的线性同余方程组,wa了一早晨不知道哪里错了,估计是所有数的lcm求错了???不解,后来没有独立的求lcm,而是用合并方程的最后一个lcm就AC了,(主要是一开始没想到用这个。。。还另外求,智商拙计啊)code:#include #include #include #define LL __int

2012-09-22 10:11:45 486

原创 hdu4091 Zombie’s Treasure Chest

跟省赛差不多的一道题,贪心+背包,对于一个最小公倍数,肯定有最优解。#include #include #include #define LL __int64using namespace std;LL gcd(LL a, LL b){ return b ? gcd( b, a % b) : a;}LL lcm(LL a, LL b){ return

2012-09-21 20:33:12 915

原创 hdu1558 Segment set

屌丝真心觉得这题的计算几何味道远大于并查集,花了两天时间才想明白怎么判断两条直线相交,结果还写不对,。。。。。code:#include #include using namespace std;const double eps=1e-8;int decmp(double n){ if(fabs(n)<eps) { return 0;

2012-09-21 13:24:05 331

原创 hdu4291 A Short problem

完全被虐啊,见识太少,完全没有意识到取模必定会有循环节的问题,所以束手无策。。。。。先暴力本地算出最外层取模的循环节,在依次往里推循环节,还需要注意两个long long型相乘的溢出问题,不过这道题好像没有这么极端的数据code:#include #include #define LL __int64using namespace std;LL modular_multi(

2012-09-18 22:53:40 316

原创 hdu2527 Safe Or Unsafe

哈夫曼编码问题,因为只需要求权值,所以不必建立哈夫曼数,只需要按照贪心的思想求权就可以code:#include #include #include using namespace std;char buf[100];multiset s;int n,cnt[26];//采用2进制的哈夫曼,clen进制数int huffman(char str[],int clen){

2012-09-15 16:01:22 574

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除