
挑战程序设计竞赛(第2版) 习题例题解
文章平均质量分 82
TaoSama
The ACM road begins.
展开
-
POJ 3484 Showstopper (二分搜索)
ShowstopperTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1429 Accepted: 422DescriptionData-mining huge data sets can be a painful and long lasting p原创 2015-05-13 23:51:27 · 813 阅读 · 0 评论 -
POJ 3641 Pseudoprime numbers (快速幂、素性测试)
Pseudoprime numbersTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7076 Accepted: 2900DescriptionFermat's theorem states that for any prime number p a原创 2015-03-31 20:25:36 · 597 阅读 · 0 评论 -
POJ 3292 Semi-prime H-numbers (变形埃氏筛法)
Semi-prime H-numbersTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7777 Accepted: 3364DescriptionThis problem is based on an exercise of David Hilber原创 2015-03-31 20:17:26 · 448 阅读 · 0 评论 -
POJ 3421 X-factor Chains (约数枚举)
X-factor ChainsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5605 Accepted: 1770DescriptionGiven a positive integer X, an X-factor chain of length m原创 2015-03-31 20:16:07 · 629 阅读 · 0 评论 -
AOJ 0009 Prime Number (埃氏筛法)
Prime NumberTime Limit : 1 sec, Memory Limit : 65536 KB Japanese version is herePrime NumberWrite a program which reads an integer n and prints the number of prime numbers which原创 2015-03-31 20:10:59 · 663 阅读 · 0 评论 -
POJ 1930 Dead Fraction (小数化分数)
Dead FractionTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 2080 Accepted: 661DescriptionMike is frantically scrambling to finish his thesis at the l原创 2015-03-31 20:07:34 · 657 阅读 · 0 评论 -
POJ 3255 Roadblocks (dijkstra最短路)
RoadblocksTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 8382 Accepted: 3030DescriptionBessie has moved to a small farm and sometimes enjoys returnin原创 2015-03-23 21:21:20 · 516 阅读 · 0 评论 -
POJ 3723 Conscription (kruskal最大生成森林)
ConscriptionTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8479 Accepted: 2959DescriptionWindy has a country, and he wants to build an army to protec原创 2015-03-23 21:54:57 · 597 阅读 · 0 评论 -
POJ 2395 Out of Hay (MST)
Out of HayTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11853 Accepted: 4642DescriptionThe cows have run out of hay, a horrible event that must be r原创 2015-03-23 22:07:07 · 480 阅读 · 0 评论 -
AOJ 2224 Save your cat (kruskal求最大生成森林)
Save your catTime Limit : 8 sec, Memory Limit : 65536 KBProblem C: Save your catsNicholas Y. Alford was a cat lover. He had a garden in a village and kept many cats in his garden. Th原创 2015-03-23 22:04:09 · 818 阅读 · 0 评论 -
POJ 2377 Bad Cowtractors (kruskal求MST)
Bad CowtractorsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11136 Accepted: 4688DescriptionBessie has been hired to build a cheap internet network原创 2015-03-23 21:59:00 · 543 阅读 · 0 评论 -
POJ 1258 Agri-Net (prim求MST)
Agri-NetTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 42748 Accepted: 17466DescriptionFarmer John has been elected mayor of his town! One of his cam原创 2015-03-23 21:57:34 · 435 阅读 · 0 评论 -
POJ 2139 Six Degrees of Cowvin Bacon (Floyd)
Six Degrees of Cowvin BaconTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3289 Accepted: 1530DescriptionThe cows have been making movies lately, so t原创 2015-03-23 21:39:15 · 468 阅读 · 0 评论 -
AOJ 0189 Convenient Location (Floyd)
题意:求某一个办公室 到其他所有办公室的 总距离最短 办公室数 不超过10输入:多组输入,每组第一行为n (1 ≤ n ≤ 45),接下来n行是 (x, y, d),x到y的距离是d输出:办公室号 和 最短距离Floyd水题 - -AC代码如下://// AOJ 0189 Convenient Location///原创 2015-03-23 21:35:34 · 820 阅读 · 0 评论 -
POJ 3169 Layout (Bellman-Ford、差分约束)
LayoutTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7834 Accepted: 3753DescriptionLike everyone else, cows like to stand close to their friends when原创 2015-03-23 21:23:18 · 472 阅读 · 0 评论 -
POJ 1742 Coins (dp)
CoinsTime Limit: 3000MS Memory Limit: 30000KTotal Submissions: 29974 Accepted: 10171DescriptionPeople in Silverland use coins.They have coins of value A1,A2,A3.原创 2015-03-07 01:52:18 · 434 阅读 · 0 评论 -
AOJ 2170 Marked Ancestor (并查集)
Marked AncestorYou are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:M原创 2015-03-17 18:20:35 · 705 阅读 · 0 评论 -
POJ 1703 Find them, Catch them (并查集)
Find them, Catch themTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 33685 Accepted: 10399DescriptionThe police office in Tadu City decides to say end原创 2015-03-17 18:15:37 · 398 阅读 · 0 评论 -
POJ 1995 Raising Modulo Numbers (快速幂)
Raising Modulo NumbersTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 5043 Accepted: 2930DescriptionPeople are different. Some secretly read magazines原创 2015-03-31 20:27:46 · 447 阅读 · 0 评论 -
POJ 2429 GCD & LCM Inverse (大整数素性测试与因式分解)
GCD & LCM InverseTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 10429 Accepted: 1917DescriptionGiven two positive integers a and b, we can easily cal原创 2015-03-31 19:28:10 · 870 阅读 · 0 评论 -
POJ 1759 Garland (二分搜索)
GarlandTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1438 Accepted: 638DescriptionThe New Year garland consists of N lamps attached to a common wire原创 2015-05-13 23:46:35 · 835 阅读 · 0 评论 -
POJ 3662 Telephone Lines (SPFA、二分搜索)
Telephone LinesTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5204 Accepted: 1906DescriptionFarmer John wants to set up a telephone line at his farm.原创 2015-05-13 23:24:25 · 552 阅读 · 0 评论 -
POJ 2010 Moo University - Financial Aid (二分搜索)
Moo University - Financial AidTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 5758 Accepted: 1721DescriptionBessie noted that although humans have man原创 2015-05-13 23:19:00 · 425 阅读 · 0 评论 -
POJ 3273 Monthly Expense (二分搜索)
Monthly ExpenseTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 16796 Accepted: 6660DescriptionFarmer John is an astounding accounting wizard and has r原创 2015-05-13 17:40:05 · 448 阅读 · 0 评论 -
POJ 3579 Median (二分搜索)
MedianTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 4379 Accepted: 1340DescriptionGiven N numbers, X1, X2, ... , XN, let us calculate the difference原创 2015-05-13 17:59:22 · 579 阅读 · 0 评论 -
POJ 3685 Matrix (二分搜索)
MatrixTime Limit: 6000MS Memory Limit: 65536KTotal Submissions: 5131 Accepted: 1381DescriptionGiven a N × N matrix A, whose element in the i-th row and j-th col原创 2015-05-13 18:03:30 · 510 阅读 · 0 评论 -
POJ 2976 Dropping tests、3111 K Best (二分搜索)
Dropping testsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7327 Accepted: 2548DescriptionIn a certain course, you take n tests. If you get ai out o原创 2015-05-13 17:48:26 · 648 阅读 · 0 评论 -
POJ 3045 Cow Acrobats (贪心)
Cow AcrobatsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3192 Accepted: 1260DescriptionFarmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are原创 2015-05-13 17:45:36 · 546 阅读 · 0 评论 -
POJ 3104 Drying (二分搜索)
DryingTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 10066 Accepted: 2581DescriptionIt is very hard to wash and especially to dry clothes in winter.原创 2015-05-13 17:44:53 · 519 阅读 · 0 评论 -
POJ 3258 River Hopscotch (二分搜索)
River HopscotchTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 8422 Accepted: 3620DescriptionEvery year the cows hold an event featuring a peculiar ve原创 2015-05-13 17:34:26 · 510 阅读 · 0 评论 -
POJ 2456 Aggressive cows (二分搜索)
Aggressive cowsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7495 Accepted: 3743DescriptionFarmer John has built a new long barn, with N (2 His原创 2015-05-13 17:32:07 · 455 阅读 · 0 评论 -
POJ 1064 Cable master (二分搜索)
Cable masterTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 27755 Accepted: 5917DescriptionInhabitants of the Wonderland have decided to hold a region原创 2015-05-13 17:29:22 · 479 阅读 · 0 评论 -
POJ 3268 Silver Cow Party (dijkstra来回最短路)
Silver Cow PartyTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 13576 Accepted: 6123DescriptionOne cow from each of N farms (1 ≤ N ≤ 1000) convenientl原创 2015-03-23 21:43:52 · 490 阅读 · 0 评论 -
AOJ 2200 Mr. Rito Post Office (Floyd预处理、dp)
快递到了:你是某个岛国(ACM-ICPC Japan)上的一个苦逼程序员,你有一个当邮递员的好基友利腾桑遇到麻烦了:全岛有一些镇子通过水路和旱路相连,走水路必须要用船,在X处下船了船就停在X处。而且岛上只有一条船,下次想走水路还是得回到X处才行;两个镇子之间可能有两条以上的水路或旱路;邮递员必须按照清单上的镇子顺序送快递(镇子可能重复,并且对于重复的镇子不允许一次性处理,比如ABCB的话B一定要按原创 2015-03-23 21:52:13 · 1072 阅读 · 0 评论 -
Uva 10006 Carmichael Numbers (快速幂)
照题意implemente就好~ 然后快速幂~ AC代码如下://// Uva 10006 Carmichael Numbers//// Created by TaoSama on 2015-03-24// Copyright (c) 2015 TaoSama. All rights reserved.//#include #include #include #i原创 2015-03-31 20:21:40 · 491 阅读 · 0 评论 -
AOJ 2249 Road Construction (dijkstra最短路)
Road ConstructionTime Limit : 8 sec, Memory Limit : 65536 KBProblem H: Road ConstructionKing Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom.原创 2015-03-23 21:48:33 · 888 阅读 · 0 评论 -
POJ 3126 Prime Path (bfs、埃氏筛法)
Prime PathTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 12750 Accepted: 7219DescriptionThe ministers of the cabinet were quite upset by the message原创 2015-03-31 20:14:18 · 467 阅读 · 0 评论 -
POJ 2236 Wireless Network (并查集)
Wireless NetworkTime Limit: 10000MS Memory Limit: 65536KTotal Submissions: 17584 Accepted: 7410DescriptionAn earthquake takes place in Southeast Asia. The ACM (原创 2015-03-17 18:14:09 · 438 阅读 · 0 评论 -
POJ 1182 食物链 (并查集)
食物链Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 48713 Accepted: 14202Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动原创 2015-03-17 13:40:42 · 428 阅读 · 0 评论 -
POJ 1017 Packets (贪心)
PacketsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 45720 Accepted: 15454DescriptionA factory produces products packed in square packets of the sam原创 2015-02-23 22:59:48 · 423 阅读 · 0 评论