摘要:一.最小生成树:连通N个点的边权值总和最小的树。 二.时间复杂度 Prim算法:时间复杂度O(|V|2+|E|),O(|E|log|V|) Kruskal算法:时间复杂度O(|E|log|E|) 算法的选择: 从图的稀疏程度考虑(稠密图Prim,稀疏图Kruskal或Prim + Heap) 三.具
阅读全文
摘要:H - 最小生成树模板+1(适合Prim) UVA - 10369 The Department of National Defence (DND) wishes to connect several northern outposts by a wireless network. Two diff
阅读全文
摘要:G - 最小生成树模板(适合Kruskal) UVALive - 2515 You are assigned to design network connections between certain points in a wide area. You are given a set of poi
阅读全文
摘要:头文件:#include <queue> 一.申明方式 struct cmp { bool operator ()(int x, int y) { return x > y; // 小的优先级高 } }; priority_queue<int, vector<int>, cmp> q; 3.友元函数
阅读全文
摘要:一.关于浮点数的输入输出
scanf :floot : %f
double : %lf
long double : %Lf
printf :floot : %f
double : %f(用%lf的话会出很多奇奇怪怪的问题,poj好像必须用%f,不然wa(惨痛教训,bug找了半天,没想到是错在这))
long double : %Lf
二.1.Java 类名称必须为Main
2.java中字符串String是不可以修改的,要修改只能转换为字符数组.
三.memset函数:很多数都不能直接用memset赋值,因为memset是一个字节一个字节赋值的。(所以若要赋值的那个数转成2进制之后每个字节都是一样的话才能用memset)
可行:
memset(a,0,sizeof(a))//因为0低8为00000000,而32位就是32个0
memset(a,-1,sizeof(a))//因为1低8为11111111,而32位就是32个1
memset(a,0x3f3
阅读全文
摘要:1.最大公约数,最小公倍数 int gcd(int x,int y) { int z=y; while(x%y!=0) { z=x%y; x=y; y=z; } return z; } int lcm(int x,int y) { return x*y/gcd(x,y); } 2.快速幂 1 int
阅读全文
摘要:UVA - 11987 Almost Union-Find I hope you know the beautiful Union-Find structure. In this problem, you’re to implement something similar, but not iden
阅读全文
摘要:POJ - 2492 http://poj.org/problem?id=2492 Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that th
阅读全文
摘要:H - 因为司是一个容易让自己去忍受的人 HDU - 6201 Kelukin is a businessman. Every day, he travels around cities to do some business. On August 17th, in memory of a grea
阅读全文
摘要:F - 你这是第一次让我看到落泪了呢 POJ - 3661 The cows are trying to become better athletes, so Bessie is running on a track for exactly N (1 ≤ N ≤ 10...
阅读全文
摘要:E - 在摩天轮转完这一圈结束掉,好吗? HDU - 1561 ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克...
阅读全文
摘要:调查问卷 Accepts: 401 Submissions: 1731 Time Limit: 6500/6000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Problem Descr...
阅读全文
摘要:子串查询 Accepts: 1262 Submissions: 5335 Time Limit: 3500/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Problem Desc...
阅读全文
摘要:J - Chores POJ - 1949 Farmer John's family pitches in with the chores during milking, doing all the chores as quickly as possible. At ...
阅读全文
摘要:I - Bone Collector HDU - 2602 Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to c...
阅读全文
摘要:H - Piggy-Bank HDU - 1114 Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main...
阅读全文
摘要:G - Bridging signals POJ - 1631 'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the ...
阅读全文
摘要:F - Anniversary party HDU - 1520 There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The Uni...
阅读全文
摘要:E - Longest Regular Bracket Sequence CodeForces - 5C This is yet another problem dealing with regular bracket sequences.We should remi...
阅读全文
摘要:K - UZI HDU - 2102 可怜的公主在一次次被魔王掳走一次次被骑士们救回来之后,而今,不幸的她再一次面临生命的考验。魔王已经发出消息说将在T时刻吃掉公主,因为他听信谣言说吃公主的肉也能长生不老。年迈的国王正是心急如焚,告招天下勇士来拯救公主。不过公主早已习...
阅读全文
摘要:J - 最强王者 POJ - 1753 Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of...
阅读全文
摘要:I - 超凡大师 CSU - 2031 The Barareh village is on fire due to the attack of the virtual enemy. Several places are already on fire and the ...
阅读全文
摘要:H - 钻石 CSU - 1224 ACM小组的Samsara和Staginner对中国象棋特别感兴趣,尤其对马(可能是因为这个棋子的走法比较多吧)的使用进行深入研究。今天他们又在 构思一个古怪的棋局:假如Samsara只有一个马了,而Staginner又只剩下一个将...
阅读全文
摘要:E - 白银 CSU - 1726 4月16日,日本熊本地区强震后,受灾严重的阿苏市一养猪场倒塌,幸运的是,猪圈里很多头猪依然坚强存活。当地15名消防员耗时一天解救围困的“猪坚强”。不过与在废墟中靠吃木炭饮雨水存活36天的中国汶川“猪坚强”相比,熊本的猪可没那么幸运,...
阅读全文
摘要:D - 青铜一 HDU - 1429 Ignatius再次被魔王抓走了(搞不懂他咋这么讨魔王喜欢)…… 这次魔王汲取了上次的教训,把Ignatius关在一个n*m的地牢里,并在地牢的某些地方安装了带锁的门,钥匙藏在地牢另外的某些地方。刚开始Ignatius被关在(sx...
阅读全文
摘要:C - 青铜五 HDU - 2717 Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a ...
阅读全文
摘要:B - 小学生 POJ - 3126 The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all...
阅读全文
摘要:A - 刚入坑 ZOJ - 1709 The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works w...
阅读全文
摘要:I - 剪枝 0。O HDU - 1455 George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he...
阅读全文
摘要:H - 连通分量 POJ - 3620 Farmer John's farm was flooded in the most recent storm, a fact only aggravated by the information that his cows a...
阅读全文
摘要:F - DFS枚举 CSU - 2087 As is known to all, Wells doesn't have a good command of English. As a result, some unfamiliar words, which may c...
阅读全文
摘要:D - Prime Ring Problem HDU - 1016 A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle...
阅读全文
摘要:A - 后序遍历 HihoCoder - 1049 描述在参与过了美食节之后,小Hi和小Ho在别的地方又玩耍了一阵子,在这个过程中,小Ho得到了一个非常有意思的玩具——一棵由小球和木棍连接起来的二叉树!小Ho对这棵二叉树爱不释手,于是给它的每一个节点都标记了一个标号—...
阅读全文
摘要:E - ( ;´Д`) URAL - 1081 Consider all the sequences with length (0 #include #include #include #include typedef long long LL;using name...
阅读全文