摘要:#include #define LL long long LL gcd(LL a,LL b) { if(a%b==0) return b; else return gcd(b,a%b); } LL lcm(LL a,LL b) { return (a/gcd(a,b)*b);//如果是int,这样处理可以防止溢出 } int mai...
阅读全文
摘要:1012 最小公倍数LCM 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 1012 最小公倍数LCM 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 1012 最小公倍数LCM 基准时间限制:1 秒 空间限制:131072 K
阅读全文
摘要:1011 最大公约数GCD 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 1011 最大公约数GCD 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 1011 最大公约数GCD 基准时间限制:1 秒 空间限制:131072 K
阅读全文
摘要:Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 46519 Accepted: 19915 Description Flip game is played on a rectangular 4x4 field
阅读全文
摘要:7.3.1增量构造法 思路:一次选出一个元素放到集合中。自己对于递归的理解还是不够,这里虽然没有明确给出递归停止条件,但是如果无法继续添加元素,就不会再继续递归,然后就是我头疼的回溯啦。 7.3.2位向量法 思路:构造一个位向量a[i],如果a[i]=1,当且仅当i在集合子集a中。 7.3.3二进制
阅读全文
摘要:1057 N的阶乘 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 1057 N的阶乘 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 1057 N的阶乘 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基
阅读全文
摘要:1008 N的阶乘 mod P 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 1008 N的阶乘 mod P 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 1008 N的阶乘 mod P 基准时间限制:1 秒 空间限制:13
阅读全文
摘要:1384 全排列 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 1384 全排列 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 1384 全排列 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题
阅读全文
摘要:There are many pretty girls in Wuhan University, and as we know, every girl loves pretty clothes, so do they. One day some of them got a huge rectangu
阅读全文
摘要:Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irrever
阅读全文
摘要:在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。 Input每行只有一个正整数N,N小于32768。Output对应每个输入,输出兑换方法数。Sample Input Sample Output
阅读全文
摘要:In the country of ALPC , Xiaoqian is a very famous mathematician. She is immersed in calculate, and she want to use the minimum number of coins in eve
阅读全文
摘要:题目描述 排列与组合是常用的数学方法。 先给一个正整数 ( 1 < = n < = 10 ) 例如n=3,所有组合,并且按字典序输出: 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 排列与组合是常用的数学方法。 先给一个正整数 ( 1 < = n < = 10 ) 例如n=
阅读全文
摘要:1136 欧拉函数 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 1136 欧拉函数 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 1136 欧拉函数 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基
阅读全文
摘要:Marsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. Th
阅读全文
摘要:对于吃货来说,过年最幸福的事就是吃了,没有之一! 但是对于女生来说,卡路里(热量)是天敌啊! 资深美女湫湫深谙“胖来如山倒,胖去如抽丝”的道理,所以她希望你能帮忙制定一个食谱,能使她吃得开心的同时,不会制造太多的天敌。 当然,为了方便你制作食谱,湫湫给了你每日食物清单,上面描述了当天她想吃的每种食物
阅读全文
摘要:We all know that English is very important, so Ahui strive for this in order to learn more English words. To know that word has its value and complexi
阅读全文
摘要:Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided t
阅读全文
摘要:Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided t
阅读全文
摘要:7.2.1 生成1~n的排列 这就是递归枚举啦~ 7.2.2生成可重集的排列(默认升序) 输入数组,并按字典序输出数组各元素的全排列 7.2.3 解答树(额,关于这个知识点的学习,只能说自己了解了一下,具体怎么实现,以后遇到再学习) 7.2.4 下一个排列 利用了c++的stl里的next_perm
阅读全文
摘要:题目描述 鲁宾逊先生有一只宠物猴,名叫多多。这天,他们两个正沿着乡间小路散步,突然发现路边的告示牌上贴着一张小小的纸条:“欢迎免费品尝我种的花生!——熊字”。 鲁宾逊先生和多多都很开心,因为花生正是他们的最爱。在告示牌背后,路边真的有一块花生田,花生植株整齐地排列成矩形网格(如图1)。有经验的多多一
阅读全文
摘要:最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或
阅读全文
摘要:The title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't
阅读全文
摘要:参考的博客~~~~ http://blog.csdn.net/wlx65003/article/details/51149196 新建一个批处理文件,右键新建一个文本文档,重命名为“对拍程序.bat”。(注意,平时windows是隐藏了文件后缀名的,我们需要在图片所示的位置把隐藏的文件后缀名显现再重
阅读全文
摘要:急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。 请问:你用有限的资金最多能采购多少公斤粮食呢? 后记: 人生是一个充满了变数的生命过程,天灾、人祸、病痛是
阅读全文
摘要:题目描述 某地区发生了地震,灾区已经非常困难,灾民急需一些帐篷、衣物、食品和血浆等物资。可通往灾区的道路到处都是塌方,70%以上的路面损坏,桥梁全部被毁。国家立即启动应急预案,展开史上最大强度的非作战式的空运行动,准备向灾区投放急需物资。 一方有难,八方支援。现在已知有N个地方分别有A1,A2,….
阅读全文
摘要:题目描述 神秘的海洋,惊险的探险之路,打捞海底宝藏,激烈的海战,海盗劫富等等。加勒比海盗,你知道吧?杰克船长驾驶着自己的的战船黑珍珠1号要征服各个海岛的海盜,最后成为海盗王。 这是一个由海洋、岛屿和海盗组成的危险世界。杰克船长准备从自己所占领的岛屿A开始征程,逐个去占领每一个岛屿。面对危险重重的海洋
阅读全文
摘要:题目描述 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。 给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费
阅读全文
摘要:(1):按位运算符&:例如:0 & 0 = 0, 0 & 1 = 0, 1 & 0 = 0, 1 & 1 = 1 即同为 1 的位,结果为 1,否则结果为 0。 (2)按位或运算符|:例如:0 | 0 = 0, 0 | 1 = 1, 1 | 0 = 1, 1 | 1 = 1即只要有1个是1的位,结果
阅读全文
摘要:费马小定理:当p是一个质数时,且a和p互质,有ap-1=1(mod p) (欧拉定理的一种特殊情况) 欧拉定理:如果a和n互质,那么aφ(n)=1(mod n) 对于任意a,b,n就有 ab=aφ(n)+b mod φ(n)(mod n) 处理b数值较大的情况 ,采用分治思想,复杂度为O(logn)
阅读全文
摘要:这个暑假只是了解了一些比较简单的算法,明天呢,集训就算是结束了,虽然,距离开学还有13天,但是对于我来说,算法学习才刚刚开始,自己要达到既定的目标,还需要付出很多时间和精力,发这篇博客也是为了督促我自己去完成这个falg。 本来想的是每个专题进行练习,但是为了系统性的学习算法,自己还是决定按照大佬的
阅读全文
摘要:Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used t
阅读全文
摘要:先明确欧拉函数:计算任意给定的正整数n,在小于等于n的正整数中和n构成互质关系的正整数个数,比如φ(8) = 4,因为1,3,5,7都与8互质 性质1:n=1时,φ(1) = 1; 性质2:如果n是质数,那么φ(n) = n-1,因为质数与小于它的每一个数都构成质数关系 性质3:如果 n = p^k
阅读全文
摘要:质数(素数):指大于1的所有自然数中,除了1和自身,不能被其它自然数整除的数 合数:比1大,但不是素数的数称为合数,合数除了被1和自身整除,还能被其它数整除 质因数(素因数或质因子):能整除给定正整数的质数,除1以外,两个没有其它共同质因子的正整数称为互质 1和0既非素数又非合数 素数筛法原理:素数
阅读全文
摘要:Description The multiplicative persistence of a number is defined by Neil Sloane (Neil J.A. Sloane in The Persistence of a Number published in Journal
阅读全文
摘要:As a basketball fan, Mike is also fond of collecting basketball player cards. But as a student, he can not always get the money to buy new cards, so s
阅读全文
摘要:Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 33882 Accepted: 14173 Special Judge Description Given a positive integer
阅读全文
摘要:1214 - Large Division PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB Given two integers, a and b, you should check whether
阅读全文
摘要:A - Catch That Cow Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤
阅读全文
摘要:食物链 Description 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X
阅读全文
摘要:Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize
阅读全文
摘要:~~~~连续三道水题,也只能用提高手速这样理由来安慰自己了,不过,从d题数组超限自己改为边存边合并的方法看来还是有收获吧,只能这样强行“收获了”(泪目) 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不
阅读全文
摘要:Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to
阅读全文
摘要:The Windy's Description The Windy's is a world famous toy factory that owns M top-class workshop to make toys. This year the manager receives N orders
阅读全文
摘要:Young naturalist Bill studies ants in school. His ants feed on plant-louses that live on apple trees. Each ant colony needs its own apple tree to feed
阅读全文
摘要:Last year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve difficu
阅读全文
摘要:There is a kind of special fish in the East Lake where is closed to campus of Wuhan University. It’s hard to say which gender of those fish are, becau
阅读全文
摘要:There are N cities in our country, and M one-way roads connecting them. Now Little Tom wants to make several cyclic tours, which satisfy that, each cy
阅读全文
摘要:Jimmy invents an interesting card game. There are N cards, each of which contains a string Si. Jimmy wants to stick them into several circles, and eac
阅读全文
摘要:On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to
阅读全文
摘要:今天下午看了一下午的km算法,因为大佬的博客介绍非常简短,所以自己一直没有弄清楚一些细节问题,好在回来翻到了一个比较好的csdn专栏,介绍比较详细,自己才算弄懂了很多疑惑的地方,二分图最佳完美匹配。 总结一下算法: 思想:km算法就是改变一些可行点的标号,不断增加图中可行边的总数,直到图中存在仅由可
阅读全文
摘要:传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子。 这可是一件大事,关系到人民的住房问题啊。村里共有n间房间,刚好有n家老百姓,考虑到每家都要有房住(如果有老百姓没房子住的话,容易引起不安定因素),每家必须分配到一间房子且只能得到一间房子。 另一方面,村长和另外的村领
阅读全文
摘要:又开始瞎折腾了,不过总得为自己刷题之外的生活找点乐子吧,今天搜算法看到了一个不错的网址,先收藏起来,晚上回去弄 1:如何添加flagcounter:http://blog.sina.com.cn/s/blog_5f1f4dc70100eudf.html 2:制定访问量的页面:http://www.a
阅读全文
摘要:You are given a 2D board where in some cells there are gold. You want to fill the board with 2 x 1 dominoes such that all gold are covered. You may us
阅读全文
摘要:You run a marriage media. You take some profiles for men and women, and your task is to arrange as much marriages as you can. But after reading their
阅读全文
摘要:Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids
阅读全文
摘要:Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an inter
阅读全文
摘要:Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possible
阅读全文
摘要:Give you a matrix(only contains 0 or 1),every time you can select a row or a column and delete all the '1' in this row or this column . Your task is t
阅读全文
摘要:As we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. Scheduling problems d
阅读全文
摘要:the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is def
阅读全文
摘要:先奉上科普文一篇,估计得等到大二学校才给上这种课吧A记录(主机名解析)CNAME(别名解析) 第一步: 1)登陆Godaddy账户,在产品列表,点击"域名"->进入"管理DNS". 2)下图箭头指示的是我们需要添加的两个新的解析记录,一开始只有默认的最后两个哟,我们添加新的解析记录,点击"添加",选
阅读全文
摘要:这篇别给我再封了 我就因为这篇被csdn锁了两次啊~~~~【这是如何借助wordpress搭建独立博客中的一个小步骤,当然其实登陆了cpanel以后,实现过程都一样 先照例奉上链接 wordpress下载链接 第一步: 1)在登陆cpanel后,我们先找到“数据库”,点击“MySQl数据库”(自己是
阅读全文
摘要:过山车Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 23353 Accepted Submission(s): 10128Probl...
阅读全文
摘要:基本思想:先初始化匹配M为空,找到图中的一条相对于M的增广路P。对P上的路径取反,更新M,。再次寻找增广路,若不存在增广路算法结束。(有一点点稍微难理解,自己手动模拟一下这个过程就知道啦)#include#include#define N 101int book[N],match[N];int e[...
阅读全文
摘要:Theme SectionProblem DescriptionIt's time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play o...
阅读全文
摘要:Best RewardProblem DescriptionAfter an uphill battle, General Li won a great victory. Now the head of state decide to reward him with honor and treasu...
阅读全文
摘要:这是如何借助wordpress搭建独立博客的其中一个步骤,当然也可以单独实现先甩上所需要的软件链接:wordpress下载链接XAMPPS下载链接 百度经验里也有这个,但是由于XAMPPS已经更新到1.9.4版本,而百度经验仍为1.8.3版本,使用过程难免不同,所以不熟悉xampps的人(比如我)...
阅读全文
摘要:前情提要:自己写这篇博客只是为了督促自己把一件事完成到底,如果有什么写的不对的,欢迎纠正~~~ by chengdongni 2017年8月10号23:30 下面开始正式介绍。 ——————————此处留于科普,先大致讲一下搭建过程,科普留于以后有时间慢慢来———————— 第一步:买域名。自己对比
阅读全文
摘要:这两天呢,一直在被小伙伴们快ak的恐惧支配,G题杭电的数据很水,但是自己还是选择不水过,用扩展kmp去写,网上的资料很多,自己选了一个最简洁的模板,不用再写一个求next数组的函数,直接调用前特殊处理下exkmp函数就既可以求next数组,又可以求ex数组啦,hh谁说鱼与熊掌不可兼得,这不就是吗~但
阅读全文
摘要:Problem DescriptionGenerally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two st...
阅读全文
摘要:PeriodProblem DescriptionFor each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we wa...
阅读全文
摘要:Seek the Name, Seek the FameDescriptionThe little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat t...
阅读全文
摘要:Simpsons’ Hidden TalentsProblem DescriptionHomer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah,...
阅读全文
摘要:/*主函数里初始化和调用*//*next[0] = 0;exkmp(s2+1,s2,next+1,next);exkmp(s1,s2,ex,next);*//*扩展kmp算法可以用o(n+m)的复杂度求出字符串s1的任意后缀与字符串s2的最长公共前缀*//*扩展kmp算法的next[i]==j表示s...
阅读全文
摘要:Problem DescriptionThe French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulip...
阅读全文
摘要:Cyclic NacklaceProblem DescriptionCC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any sur...
阅读全文
摘要:今天下午刚好看了一道最小循环节的题,感觉还是挺有意思的,不过自己还是看了一个下午才理解点,感觉自己好菜哎~~~kmp算法里的next数组还有一个性质就是j-next[j]是s2的最小循环节 稍微修改下next数组的定义,这里是修改前的定义链接,我们不再要求s2[j]和s2[k]不同,...
阅读全文
摘要:s1为匹配串,s2为模式串。kmp算法中的next数组称为失配指针,表示s1[i]和s2[j]匹配失败时,最有效率的方法是让s1[i]和s2[j]中的哪个元素进行匹配。 next数组有很多种定义方式,自己选了1种作为模板。 void get_NEXT()//建立next数组 { int j,k; N
阅读全文
摘要:Number SequenceTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 28715 Accepted Submission(s...
阅读全文
摘要:人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全世界科学家思考的问题,同样的问题Eddy也一直在思考,因为他在很小的时候就知道亲和串如何判断了,但是发现,现在长大了却不知道怎么去判断亲和串了,于是他只好又再一次来请教聪明且乐于助人的你来解决这个问题。 亲和串的定义是这样的:给定两个字符串s1...
阅读全文
摘要:Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but ...
阅读全文
摘要:BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical commun...
阅读全文
摘要:Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whe...
阅读全文
摘要:While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path tha...
阅读全文
摘要:题目描述一天,ykc在学校闲的无聊,于是决定上街买点吃的,ykc很懒,本来就不是很像逛街,于是找来了czl帮他买,这里应该有滑稽,而czl也不愿为ykc买东西吃,但是ykc很强势,非让他去买,呢没办法了,然而czl还有很多事要做,没呢么多时间帮ykc,而这条小吃街又很长,有n家店,n有50000这么...
阅读全文
摘要:某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处...
阅读全文
摘要:题目描述正在入侵艾泽拉斯的古尔丹偶然间得到了一颗邪能炸弹,经过研究,他发现这是一颗威力极其巨大且难以控制的炸弹。但是精通邪能的古尔丹突然有了一个大胆的想法,他对炸弹进行了一些小小的改造。这使得炸弹需要n天的充能才能爆炸,在这n天中,每天炸弹的邪能值都会产生波动,波动值为xi,古尔丹唯一能控制的是使邪...
阅读全文
摘要:1279: 简单的背包问题时间限制: 1 秒 内存限制: 32 MB提交: 363 解决: 21提交 状态 题目描述相信大家都学过背包问题了吧,那么现在我就考大家一个问题。有n个物品,每个物品有它的重量w,价值v,现在有一个容量为W的背包,问你在不超过背包容量的情况下,能装下的物品的最大价值是多...
阅读全文
摘要:在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗? Input输入包括多组数据。每组数据第一行是两个整数N、M(N#define N 110#...
阅读全文
摘要:问题 F: 还是畅通工程时间限制: 1 Sec 内存限制: 32 MB提交: 18 解决: 10[提交][状态][讨论版]题目描述 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相...
阅读全文
摘要:这里是先建立最大堆,再从小到大输出堆元素。具体实现及其解释见代码。总结:像这样支持插入元素和寻找最大(小)值元素的数据结构称为优先队列。堆就是优先队列的实现,很大程度的降低了时间复杂度。另外Dijkstra算法每次找离源点最近的一个顶点也可以用堆来优化,使算法复杂度降到O((m+n)...
阅读全文
摘要:There are N (2#include#include#include#define inf 9999999 int e[1100][1100];int book[1100],a[1100];int dis[1100];int isprime[2010000];int Min(int a,in...
阅读全文
摘要:There exists a world within our world A world beneath what we call cyberspace. A world protected by firewalls, passwords and the most advanced securit...
阅读全文
摘要:The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ag...
阅读全文
摘要:描述最近,小Hi很喜欢玩的一款游戏模拟城市开放出了新Mod,在这个Mod中,玩家可以拥有不止一个城市了!但是,问题也接踵而来——小Hi现在手上拥有N座城市,且已知这N座城市中任意两座城市之间建造道路所需要的费用,小Hi希望知道,最少花费多少就可以使得任意两座城市都可以通过所建造的道路互相到达(假设有...
阅读全文
摘要:省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 Input测试输入包含若干测试用例。每个测试用例的第1行给出评...
阅读全文
摘要:ACM模板【最短路】:最短路是不包含回路的简单路径。【Floyed】多源最短路,即要求求出图中每两个顶点之间的最短路。虽然Floyed的复杂度是O(n^3),但是4行却简单很多,本质上是动态规划算法。 思想:从i号顶点到j号顶点只经过前k号顶点的最短路径。#define INF 99...
阅读全文
摘要:ACM模板【快速幂取模运算】//取模运算(a*b)%c = (a%c)*(b%c)%c int PowerMod(int a, int b, int c){ int ans = 1; a = a % c; while(b>0) { if(b % ...
阅读全文
摘要:ACM模板C++queue的应用struct note{ int x; //横坐标 int step; //步数 int y; //纵坐标 }; void BFS(note front_head)//BFS { queueQ;//建立空队...
阅读全文