摘要: 有一棵由N个结点构成的树,每一条边上都有其对应的权值。现在给定起点,求从该点出发的一条路径(至少有一条边)使得这条路径上的权值之和最大,并输出这个最大值。 Input 第一行一个正整数T,代表数据组数。每组数据第一行两个正整数n(2<=n<=10^5),s(1<=s<=n),分别表示树结点数目以及给 阅读全文
posted @ 2018-07-29 20:30 StarHai 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 链接:http://codeforces.com/contest/401/problem/D 题意:给出一个数字num和m,问通过重新排列num中的各位数字中有多少个数(mod m)=0,直接枚举全排列肯定不行,可以用状压dp来搞.. dp[S][k]表示选了num中的S且(mod m)=k的方案种 阅读全文
posted @ 2018-07-29 20:21 StarHai 阅读(203) 评论(0) 推荐(0) 编辑
摘要: Input: standard inputOutput: standard output Time Limit: 2 seconds The small sawmill in Mission, British Columbia, has developed a brand new way of pa 阅读全文
posted @ 2018-07-29 20:12 StarHai 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Marica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn't live in the same city, she started preparing 阅读全文
posted @ 2018-07-29 19:56 StarHai 阅读(454) 评论(0) 推荐(0) 编辑
摘要: 1 A*算法 A*算法在人工智能中是一种典型的启发式搜索算法,启发中的估价是用估价函数表示的: 其中f(n)是节点n的估价函数,g(n)表示实际状态空间中从初始节点到n节点的实际代价,h(n)是从n到目标节点最佳路径的估计代价。另外定义h'(n)为n到目标节点最佳路径的实际值。如果h'(n)≥h(n 阅读全文
posted @ 2018-07-29 19:56 StarHai 阅读(2834) 评论(0) 推荐(0) 编辑
摘要: 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,....VK,V1,那么必须满足K>2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区。现在86... 阅读全文
posted @ 2018-07-29 19:56 StarHai 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Since 1945, when the first nuclear bomb was exploded by the Manhattan Project team in the US, the number of nuclear weapons have soar... 阅读全文
posted @ 2018-07-29 19:56 StarHai 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Weiwei is a software engineer of ShiningSoft. He has just excellently fulfilled a software project with his fellow workers. His boss i... 阅读全文
posted @ 2018-07-29 19:56 StarHai 阅读(385) 评论(0) 推荐(0) 编辑
摘要: 喜马拉雅山上的猴子Time Limit: 1000 MS Memory Limit: 256 MBSubmit Status余周周告诉我喜马拉雅山上有猴子,他们知道点石成金的方法。我不信,于是余周周带我去喜马拉雅山拜访猴子。喜马拉雅山上有n个猴子聚落,不妨叫... 阅读全文
posted @ 2018-07-29 19:56 StarHai 阅读(368) 评论(0) 推荐(0) 编辑
摘要: Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the sa... 阅读全文
posted @ 2018-07-29 19:55 StarHai 阅读(263) 评论(0) 推荐(0) 编辑
摘要: oooccc1 is a Software Engineer who has to ride to the work place every Monday through Friday. For a long period, he went to office w... 阅读全文
posted @ 2018-07-29 19:55 StarHai 阅读(277) 评论(0) 推荐(0) 编辑
摘要: Henry decides to develop a web site, which will provide the service of transit search. But he can only get the transit data of Guangzh... 阅读全文
posted @ 2018-07-29 19:55 StarHai 阅读(287) 评论(0) 推荐(0) 编辑
摘要: A group of thieves is approaching a museum in the country of zjsxzy,now they are in city A,and the museum is in city B,where keeps man... 阅读全文
posted @ 2018-07-29 19:55 StarHai 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Ali has taken the Computer Organization and Architecture course this term. He learned that there may be dependence between instruction... 阅读全文
posted @ 2018-07-29 19:55 StarHai 阅读(356) 评论(0) 推荐(0) 编辑
摘要: You have been given a matrix C N*M, each element E of C N*M is positive and no more than 1000, The problem is that if there exist N nu... 阅读全文
posted @ 2018-07-29 19:55 StarHai 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Liyuan wanted to rewrite the famous book “Journey to the West” (“Xi You Ji” in Chinese pinyin). In the original book, the Monkey King ... 阅读全文
posted @ 2018-07-29 19:55 StarHai 阅读(243) 评论(0) 推荐(0) 编辑
摘要: F. Xor-Pathstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a rectangul... 阅读全文
posted @ 2018-07-29 19:54 StarHai 阅读(327) 评论(0) 推荐(0) 编辑
摘要: A supermarket in Tehran is open 24 hours a day every day and needs a number of cashiers to fit its need. The supermarket manager has h... 阅读全文
posted @ 2018-07-29 19:54 StarHai 阅读(382) 评论(0) 推荐(0) 编辑
摘要: It is well known that, in the period of The Three Empires, Liu Bei, the emperor of the Shu Empire, was defeated by Lu Xun, a general of the Wu Empire. 阅读全文
posted @ 2018-07-29 19:54 StarHai 阅读(306) 评论(0) 推荐(0) 编辑
摘要: You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a program that: > reads the number of intervals, their endpoints 阅读全文
posted @ 2018-07-29 19:54 StarHai 阅读(361) 评论(0) 推荐(0) 编辑