- 博客(54)
- 资源 (6)
- 收藏
- 关注
原创 hdu2824 The Euler function 欧拉函数
欧拉函数题目大意:给定两个整数a,b,计算a、b之间的欧拉函数值。算法分析:定义:对于正整数n,φ(n)是小于或等于n的正整数中,与n互质的数的数目。 例如:φ(8) = 4,因为1,3,5,7均和8互质。性质:1.若p是质数,φ(p) = p-1. 2.若n是质数p的k次幂,φ(n) = (p-1)*p^(k-1)。因为除了p的倍数都与n互质 3.欧拉函数是
2013-10-11 17:38:13 549
原创 1002. A+B for Polynomials (25)
This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each line contains the information of a p
2013-09-09 19:36:31 551
原创 Surround the Trees
Problem DescriptionThere are a lot of trees in an area. A peasant wants to buy a rope to surround all these trees. So at first he must know the minimal required length of the rope. However, he doe
2013-08-27 17:33:29 642
原创 Shape of HDU
Problem Description话说上回讲到海东集团推选老总的事情,最终的结果是XHD以微弱优势当选,从此以后,“徐队”的称呼逐渐被“徐总”所取代,海东集团(HDU)也算是名副其实了。创业是需要地盘的,HDU向钱江肉丝高新技术开发区申请一块用地,很快得到了批复,据说这是因为他们公司研发的“海东牌”老鼠药科技含量很高,预期将占全球一半以上的市场。政府划拨的这块用地是一个多边形,为了
2013-08-27 17:31:37 560
原创 Assignments
Problem DescriptionIn a factory, there are N workers to finish two types of tasks (A and B). Each type has N tasks. Each task of type A needs xi time to finish, and each task of type B needs yj ti
2013-08-27 17:29:22 767
原创 Machine Schedule
最小顶点覆盖=最大匹配#includeusing namespace std;int mat[1000][1000];int link[1000];int useif[1000];int gl,gr;int can(int t){ int i; for(i=1;i { if(useif[i]==0&&mat[t][i]) {
2013-08-23 21:46:00 409
翻译 Minimum Transport Cost
hese are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transport
2013-08-17 22:31:01 547
原创 HDU Today
Problem Description经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强。这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬浦镇陶姚村买了个房子,开始安度晚年了。这样住了一段时间,徐总对当地的交通还是不太了解。有时很郁闷,想去一个地方又不知道应该乘什么公交车,在什么地方转车
2013-08-17 10:01:59 354
原创 一个人的旅行 spfa
#include#includeusing namespace std;int head[10005];struct edge{ int from; int to; int cost; int next;}p[100006];int size;int dist[10005];bool isvisit[10005];void ini
2013-08-16 19:45:04 534
原创 一个人的旅行
Problem Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大
2013-08-16 19:16:00 415
原创 最短路
最短路Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 203 Accepted Submission(s): 112Problem Description在每年的校赛
2013-08-16 18:57:20 471
原创 Pseudoforest
Problem DescriptionIn graph theory, a pseudoforest is an undirected graph in which every connected component has at most one cycle. The maximal pseudoforests of G are the pseudoforest subgraphs of
2013-08-16 10:27:37 464
原创 Connect the Cities
Problem DescriptionIn 2100, since the sea level rise, most of the cities disappear. Though some survived cities are still connected with others, but most of them become disconnected. The governmen
2013-08-16 09:03:11 439
原创 继续畅通工程
#include#include#includeusing namespace std;struct node{int a;int b;int dis;}p[10000];bool cmp(node n1,node n2){ return n1.dis}int parent[10000];void init(int n){f
2013-08-15 22:20:04 448
原创 Eddy's picture
Eddy's pictureTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 134 Accepted Submission(s): 98Problem Description
2013-08-15 21:49:49 496
原创 Constructing Roads
这题叙述的有点小问题,两个村庄无论经过几个其他的村庄只要相连即可。所有已这是最小生成树问题,已建成的距离设为0;There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to
2013-08-14 10:43:27 374
原创 Find the nondecreasing subsequences
roblem DescriptionHow many nondecreasing subsequences can you find in the sequence S = {s1, s2, s3, ...., sn} ? For example, we assume that S = {1, 2, 3}, and you can find seven nondecreasing subs
2013-08-12 22:54:29 467
原创 敌兵布阵
roblem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。
2013-08-07 12:30:33 396
原创 See you~
See you~Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 163 Accepted Submission(s): 53Problem DescriptionNo
2013-08-07 11:37:03 416
原创 统计难题
统计难题Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submission(s): 245 Accepted Submission(s): 155 Problem DescriptionIgnat
2013-08-02 07:49:05 483
原创 Hat’s Words
#include#include#includeusing namespace std;typedef struct snode{ char str[20]; int len; bool operator { if(len return true; elsereturn false; } }S
2013-08-02 07:48:01 558
原创 What Are You Talking About
#include#includeusing namespace std;typedef struct node{node(){str=NULL;for(int i=0;i{ child[i]=NULL;}}char* str;node* child[26]; }Node;Node* root=NULL;char* se
2013-08-02 07:46:06 820
原创 How Many Answers Are Wrong
Total Submission(s): 341 Accepted Submission(s): 159 Problem DescriptionTT and FF are ... friends. Uh... very very good friends -________-bFF is a bad boy, he is always wooing
2013-07-29 22:26:31 404
原创 Junk-Mail Filter
Junk-Mail FilterTime Limit: 15000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 201 Accepted Submission(s): 70Problem Descript
2013-07-28 22:13:19 672
转载 Dragon Balls
通过这道题,对并查集的查找又有了一定的认识,初步理解了路径压缩的好处,这里,根结点的转移次数不是直接加上根结点的移动次数,而是在路径压缩的过程中逐层累加,比如有4层,根结点为1,然后第二层2,第三层3,第四层4.那么,第一层路径压缩过程中进入第二层,然后第三层,然后第四层,第四层也就是根,找到根结点,返回第三层,第三层+上第四层的转移次数,然后返回第二层,第二层转移次数加上第三层转移次数,返回第一
2013-07-24 21:34:36 511
原创 find the most comfortable road
Problem DescriptionXX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure---超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的“舒适度”有特殊要求,即乘坐过程中最高速度与最低速度的差越小乘坐越舒服 ,(理解为SARS的限速要求,flycar必须瞬
2013-07-22 21:21:07 428
转载 Rank of Tetris
自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布斯富豪榜还响。关于如何排名,这个不用说都知道是根据Rating从高到低来排,如果两个人具有相同的Rating,那就按这几个人的RP从高到低来排。终于,Lele要开始
2013-07-18 13:11:45 535
原创 Farm Irrigation
roblem DescriptionBenny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square ha
2013-06-10 17:11:36 412
原创 Is It A Tree?
Is It A Tree?Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 596 Accepted Submission(s): 205 Problem Description
2013-06-09 12:28:51 624
原创 A Bug's Life
sex保存异性,(a,b) 同性的在一个集合,a一定和sex[b]是同性的,b一定和sex[a]是同性的。Problem DescriptionBackground Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that
2013-06-07 17:14:57 620
转载 Another Eight Puzzle
Fill the following 8 circles with digits 1~8,with each number exactly once . Conntcted circles cannot be filled with two consecutive numbers.There are 17 pairs of connected cicles:A-B , A-C, A-D
2013-05-31 19:11:44 375
原创 #define is unsafe
Problem DescriptionHave you used #define in C/C++ code like the code below?#include #define MAX(a , b) ((a) > (b) ? (a) : (b))int main(){ printf("%d\n" , MAX(2 + 3 , 4)); return 0;
2013-05-31 16:47:36 715
原创 Sequence one
//去重,结合原序列。第一个重判是判断如果搜索的是子序列的第一个元素,那么判断从原始序列开始到当前位置是否已经出现过该元素, 若出现过则之前肯定搜索过该元素,则放弃该元素的搜索。 第二个重判,当搜索的不是子序列的第一个元素时,则判断子序列的前一个元素对应原始序列的位置, 然后从该位置下一个元素开始到到当前搜索的位置之前判断该元
2013-05-29 21:19:21 513
原创 N皇后问题
在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。 Output
2013-05-27 17:12:20 367
原创 Sudoku Killer
自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视。据说,在2008北京奥运会上,会将数独列为一个单独的项目进行比赛,冠军将有可能获得的一份巨大的奖品———HDU免费七日游外加lcy亲笔签名以及同hdu acm team合影留念的机会。所以全球人民前仆后继,为了奖品日夜训练茶饭不思。当然也包括初学者linle,不过他太笨了又没有多少耐性,只能做
2013-05-26 20:55:59 363
原创 蜘蛛牌
Problem Description蜘蛛牌是windows xp操作系统自带的一款纸牌游戏,游戏规则是这样的:只能将牌拖到比她大一的牌上面(A最小,K最大),如果拖动的牌上有按顺序排好的牌时,那么这些牌也跟着一起移动,游戏的目的是将所有的牌按同一花色从小到大排好,为了简单起见,我们的游戏只有同一花色的10张牌,从A到10,且随机的在一行上展开,编号从1到10,把第i号上的牌移到第j号牌上
2013-05-20 20:03:55 567
原创 Tempter of the Bone
Problem DescriptionThe doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He
2013-05-19 09:43:55 363
原创 Waiting ten thousand years for Love
最后一道搜索题,关键是划分状态。分析这道题:如果以(x,y)为状态,无法唯一确定状态。因为(‘.’ Indicate the road that Yifenfei can walk on it, or fly over it.)所以必须要(x,y,p)为状态区分。本题采用bfs+优先队列It was ten thousand years, after Demon Lemon
2013-05-17 18:41:10 723
原创 Bubble Shooter
Bubble ShooterTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 110 Accepted Submission(s): 47 Problem Description
2013-05-16 17:16:07 1187
原创 非常可乐
Problem Description大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S Input三个整数 : S 可
2013-05-14 12:16:42 375
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人