ICPC-UVA
文章平均质量分 85
UVA-OJ题解
海岛Blog
专注于程序设计及其竞赛,专注于集成电路EDA设计
展开
-
UVA11393 Tri-Isomorphism【数学推理】
Let V (G) be the vertex set of a simple graph and E(G) its edge set. An Isomorphism from a simple graph G to a simple graph H is a bijection f : V (G) → V (H) such that uv ∈ E(G) if and only if f(u)f(...原创 2020-02-28 22:30:31 · 383 阅读 · 0 评论 -
UVA11387 The 3-Regular Graph【数学推理】
The degree of a vertex in a graph is the number of edges adjacent to the vertex. A graph is 3-regular if all of its vertices have degree 3. Given an integer n, you are to build a simple undirected 3-r...原创 2020-02-28 22:20:29 · 423 阅读 · 1 评论 -
UVA11827 Maximum GCD【GCD】
Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possible pair of these integers.InputThe first line of input is an integer N (1 < N < 100) that determ...原创 2020-02-28 15:30:12 · 326 阅读 · 0 评论 -
UVA10852 Less Prime【筛选法】
Let n be an integer, 100 ≤ n ≤ 10000, find the prime number x, x ≤ n, so that n − p ∗ x is maximum, where p is an integer such that p ∗ x ≤ n < (p + 1) ∗ x.InputThe first line of the input contai...原创 2020-02-28 10:23:10 · 316 阅读 · 0 评论 -
UVA10394 Twin Primes【孪生素数】
Twin primes are pairs of primes of the form (p, p + 2). The term “twin prime” was coined by Paul Stckel (1892-1919). The first few twin primes are (3, 5), (5, 7), (11, 13), (17, 19), (29, 31), (41, 43...原创 2020-02-27 20:40:38 · 504 阅读 · 0 评论 -
UVA10311 Goldbach and Euler【筛选法+歌德巴赫猜想】
That every number which is resolvable into two prime numbers can be resolved into as many prime numbers as you like, can be illustrated and confirmed by an observation which you have formerly communic...原创 2020-02-27 20:18:47 · 371 阅读 · 0 评论 -
UVA10948 The primary problem【欧拉筛法+贪心】
Larry now lost most of his knowledge after spending a few years on deserted islands all over the place. When Ryan brought up the fact that every even number greater than 3 can represented as the sum o...原创 2020-02-27 19:58:22 · 324 阅读 · 0 评论 -
UVA11661 Burger Time?【文本处理】
Everybody knows that along the more important highways there are countless fast food restaurants. One can find easily hamburgers, hot dogs, pizzas, sandwiches … food everywhere. &nbs...原创 2020-02-27 18:30:52 · 270 阅读 · 0 评论 -
UVA11687 Digits【模拟】
A googol written out in decimal has 101 digits. A googolplex has one plus a googol digits. That’s a lot of digits! Given any number x0, define a sequence using the following re...原创 2020-02-27 08:45:42 · 472 阅读 · 0 评论 -
UVA11298 Dissecting a Hexagon【数学+找规律】
Given an integer n, determine whether it is possible to dissect a regular hexagon into n parallelograms of equal area. An example of a hexagon dissected into 3 parallelograms is given below.InputTh...原创 2020-02-27 00:02:45 · 272 阅读 · 0 评论 -
UVA11246 K-Multiple Free set【数学+找规律】
A k-multiple free set is a set of integers where there is no pair of integers where one is equal to anotherinteger multiplied by k. For example for k = 2, {1,3,4} is a valid set, but not {2,4,5}, as ...原创 2020-02-26 23:49:46 · 331 阅读 · 0 评论 -
HDU1973 POJ3126 UVA12101 LA3639 Prime Path【BFS】
Prime PathTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1388 Accepted Submission(s): 866Problem DescriptionThe ministers of the cabinet...原创 2020-02-24 14:40:04 · 420 阅读 · 0 评论 -
HDU3233 UVA12231 LA4486 Download Manager【模拟】
Download ManagerTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1563 Accepted Submission(s): 800Problem DescriptionJiajia downloads a lot...原创 2020-02-23 22:22:49 · 442 阅读 · 0 评论 -
UVA10774 Repeated Josephus【约瑟夫环+位运算】
No, I don’t want you to waste important time reading boring introduction. At first, there are n people numbered 1 to n around a circle and every second remaining person will be eliminated until only o...原创 2020-02-22 19:41:59 · 424 阅读 · 0 评论 -
UVA10771 Barbarian tribes【约瑟夫环】
In a lost land two primitive tribes coexist: Gareds and Kekas. Every summer solstice they meet and compete to decide which tribe will be the favorite of the gods for the rest of the year, following an...原创 2020-02-22 10:28:28 · 375 阅读 · 0 评论 -
UVA11351 Last Man Standing【约瑟夫环+数学】
There are n people standing in a circle waiting to be executed. Starting from the first man, k−1 people are skipped and the k-th man is executed. Then again, k − 1 people are skipped and the k-th man ...原创 2020-02-22 09:32:03 · 427 阅读 · 0 评论 -
UVA11858 LA8231 HDU3743 Frosh Week【逆序数】
During Frosh Week, students play various fun games to get to know each other and compete against other teams. In one such game, all the frosh on a team stand in a line, and are then asked to arrange t...原创 2020-02-21 20:46:37 · 314 阅读 · 0 评论 -
UVA12542 LA6149 Prime Substring【筛选法+贪心】
Given a string of digits, your task is to find the largest prime number which presents in that string. Our prime numbers are values between 2 to 100,000 only.InputEach line contains a string of digi...原创 2020-02-21 14:40:07 · 272 阅读 · 0 评论 -
UVA10924 Prime Words【筛选法】
A prime number is a number that has only two divisors: itself and the number one. Examples of prime numbers are: 1, 2, 3, 5, 17, 101 and 10007. In this problem you should read ...原创 2020-02-21 11:15:45 · 383 阅读 · 0 评论 -
UVA10235 Simply Emirp【筛选法】
An integer greater than 1 is called a prime number if its only positive divisors (factors) are 1 and itself. Prime numbers have been studied over the years by a lot of mathematicians. Applications of ...原创 2020-02-21 10:38:57 · 517 阅读 · 0 评论 -
POJ3641 UVA11287 HDU1905 Pseudoprime numbers【素数判定+快速模幂+Miller_Rabin素性测试算法】
Pseudoprime numbersTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 15471 Accepted: 6696DescriptionFermat’s theorem states that for any prime number p and for any integer a > 1, ap =...原创 2020-02-20 22:04:14 · 308 阅读 · 0 评论 -
UVA12626 I ❤ Pizza【文本】
Everybody loves pizza: Margarita, Four cheese, Salami, Caprichosa, Neapolitan, Hawaiian… The famous pizza Margarita is named after the Italian Queen Margarita of Savoy. It is said that the chef Raffae...原创 2019-12-10 08:29:27 · 352 阅读 · 0 评论 -
UVA476 Points in Figures: Rectangles【水题】
Given a list of rectangles and a list of points in the x-y plane, determine for each point which figures (if any) contain the point.InputThere will be n(≤ 10) rectangles descriptions, one per line. ...原创 2019-12-06 18:10:41 · 436 阅读 · 0 评论 -
UVa834 Continued Fractions【连分数】
问题链接:UVa834 Continued Fractions。问题简述:参见上述链接。问题分析:这是一个分数转换为连分数的问题。需要了解和掌握有关连分数的概念与表示方式,可以查看中英文版的维基百科的“连分数”。剩下的就是简单的分数计算问题了。程序说明:需要考虑特例的情况,例如,分数实际上是整数的情况。程序中不考虑约分的问题。程序中的迭代计算过程原创 2017-05-24 09:20:02 · 868 阅读 · 0 评论 -
POJ3292 UVA11105 Semi-prime H-numbers【筛法打表】
问题链接:POJ3292 UVA11105 Semi-prime H-numbers。问题简述:参见上述链接。问题分析:H-number:4n+1的数,n>=0,例如1,5,9,13,17,21,......。H-prime:H-number数并且其因子只有1和它本身。H-semi-prime:两个H-prime的乘积。H-composite:其他H-number数。...原创 2017-05-20 06:16:09 · 791 阅读 · 0 评论 -
POJ3641 UVA11287 HDU1905 Pseudoprime numbers【素数判定+快速模幂】
问题链接:POJ3641 UVA11287 HDU1905 Pseudoprime numbers。问题简述:参见上述链接。问题分析:这个问题是验证伪素数问题。p是伪素数的条件是,p不是素数并且满足ap = a (mod p)。伪素数是数论中与费尔马小定理有关的一个重要概念。程序说明:函数isprime()不是一个真正意义上的素数判断函数,只进行奇数判定,对于本原创 2017-05-20 00:17:03 · 743 阅读 · 0 评论 -
UVALive2203 UVa10042 Smith Numbers【质因数分解+素数判定+数位之和】
While skimming his phone directory in 1982, Albert Wilansky, a mathematician of Lehigh University, noticed that the telephone number of his brother-in-law H. Smith had the following peculiar property:...原创 2017-05-20 18:09:00 · 1258 阅读 · 0 评论 -
UVa10006 Carmichael Numbers【素数判定+快速模幂】
问题链接:UVa10006 Carmichael Numbers。问题简述:参见上述链接。问题分析:这是一个卡尔迈勒数判定问题,只要读懂题意就简单了。卡尔迈勒数是数论中的一个重要概念。程序说明:函数isprime()不是一个真正意义上的素数判断函数,只进行奇数判定,对于本题条件是没有问题的。函数powermod()是模幂计算函数。AC的C++语言原创 2017-05-20 19:29:50 · 1136 阅读 · 0 评论 -
UVA11292 HDU1902 POJ3646 The Dragon of Loowater【贪心】
问题链接:UVA11292 HDU1902 POJ3646 The Dragon of Loowater。题意简述:(略)问题分析:这个问题是一个典型的贪心法问题,求代价最小。由于需要用到排序函数,C++的排序函数参数比较简单,所以用C++编程。程序说明:(略)AC通过的C++语言程序如下:/* UVA11292 HDU1902 POJ364原创 2016-08-03 20:50:05 · 1271 阅读 · 0 评论 -
UVA11729 Commando War【贪心】
问题链接:UVA11729 Commando War。问题简述:有n个部下需要完成一项任务,给第i个部下交代任务需要Bi时间,执行任务需要Ji时间,要求尽早完成任务,请输出最后完成任务需要的最小总时间。这个问题是一个典型的贪心法问题,求完成任务的最短时间。用C++编程比较方便。程序说明:程序中,比起用结构表示,每一项任务用一个类对象表示,程序处理起来比较方便,所以实现了一个原创 2016-08-04 20:04:38 · 1028 阅读 · 0 评论 -
UVALive3520 UVA1590 POJ2799 ZOJ2645 IP Networks【进制+位运算】
IP NetworksTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 2392Accepted: 919DescriptionAlex is administrator of IP networks. His clients have a bunch of individual IP addresses and he decid...原创 2017-05-18 10:41:05 · 843 阅读 · 0 评论 -
UVA11039 Building designing【排序】
问题链接:UVA11039 Building designing。基础级练习题,用C++语言编写程序。问题简述:输入n个绝对值各不相等的非0整数,选择尽量多的数,排成一个序列,使得正负交替并且绝对值递增。输出其最大长度。问题分析:按照绝对值排序后,看一遍就可以了。程序说明:(略)AC的C++语言程序如下:/* UVA11039 Building designin原创 2016-08-08 16:25:47 · 1046 阅读 · 0 评论 -
UVA1368 UVALive3602 ZOJ3132 DNA Consensus String【贪心】
Regionals 2006 >> Asia - Seoul 问题链接:UVA1368 UVALive3602 ZOJ3132 DNA Consensus String问题简述:给定m个长度为n的DNA序列,求一个DNA序列,使其到所有这些序列的总hamming距离尽量小,如果有多个解,输出字典顺序的最小解。问题分析:每个DNA序列的长度相同,对每个DNA序列...原创 2016-08-01 14:06:56 · 1238 阅读 · 2 评论 -
UVA524 UVALive5270 HDU1016 ZOJ1457 Prime Ring Problem【DFS】
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 60401 Accepted Submission(s): 26099 Problem DescriptionA ...原创 2016-07-21 20:23:22 · 1866 阅读 · 0 评论 -
UVA10098 Generating Fast【全排列】
Generating permutation has always been an important problem in computer science. In this problemyou will have to generate the permutation of a given string in ascending order. Remember that youralgori原创 2017-07-03 04:00:43 · 1085 阅读 · 0 评论 -
UVA146 POJ1146 ID Codes【全排列】
ID CodesTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 6932 Accepted: 4115DescriptionIt is 2084 and the year of Big Brother has finally arrived, albeit原创 2017-07-03 04:24:18 · 1112 阅读 · 0 评论 -
UVALive5369 UVa732 HDU1515 ZOJ1004 Anagrams by Stack【DFS+堆栈】
Anagrams by StackTime Limit: 2 Seconds Memory Limit: 65536 KB How can anagrams result from sequences of stack operations? There are two sequences of stack operators which can convert TRO...原创 2017-06-12 17:06:36 · 1184 阅读 · 0 评论 -
UVALive3261 UVA1640 POJ2282 HDU1663 ZOJ2392 The Counting Problem【进制】
The Counting ProblemTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 4605 Accepted: 2363DescriptionGiven two integers a and b, we write the numbers betwe原创 2016-08-20 10:47:14 · 1060 阅读 · 0 评论 -
HDU1241 POJ1562 UVa572 UVALive5317 Oil Deposits【DFS】
Oil DepositsTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 17768 Accepted: 9440 DescriptionThe GeoSurvComp geologic survey company is responsible for detectin...原创 2016-07-14 08:43:26 · 1593 阅读 · 0 评论 -
HDU1258 POJ1564 UVA574 UVALive5319 ZOJ1711 Sum It Up【DFS】
Sum It UpTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 7926 Accepted: 4068 DescriptionGiven a specified total t and a list of n integers, find all distinct s...原创 2016-07-18 08:59:37 · 1094 阅读 · 0 评论