算法竞赛入门经典
文章平均质量分 80
努力写题的tyf
这个作者很懒,什么都没留下…
展开
-
第五章 - Ugly Numbers - uva136 - priority_queue与set
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...shows the first 11 ugly numbers. By convention, 1 is included.Write a program to fin...原创 2018-03-12 21:58:04 · 177 阅读 · 0 评论 -
第六章 - Matrix Chain Multiplication - uva442 - stack
Suppose you have to evaluate an expression like A*B*C*D*E where A,B,C,D and E are matrices.Since matrix multiplication is associative, the order in which multiplications are performed is arbitrary.How...原创 2018-04-07 21:03:09 · 297 阅读 · 0 评论 -
第六章 - Rails - uva514 - stack、模拟
There is a famous railway station in PopPush City. Country there is incredibly hilly. The stationwas built in last century. Unfortunately, funds were extremely limited that time. It was possible toest...原创 2018-04-07 21:23:53 · 182 阅读 · 0 评论 -
第六章 - uva679 - Dropping Balls (详解)
if the flag’s current value at this node is false, then the ball will first switch this flag’s value, i.e., fromthe false to the true, and then follow the left subtree of this node to keep moving down...原创 2018-04-08 21:14:53 · 277 阅读 · 0 评论 -
第四章 - Hangman Judge - uav489
In “Hangman Judge,” you are to write a program that judges a series of Hangman games. For eachgame, the answer to the puzzle is given as well as the guesses. Rules are the same as the classic gameof h...原创 2018-04-01 10:07:42 · 180 阅读 · 0 评论 -
第四章 - The Dole Queue - uva 133
In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour RhinocerosParty has decided on the following strategy. Every day all dole applicants will be placed in a largeci...原创 2018-04-01 11:39:04 · 182 阅读 · 0 评论 -
第四章 - Message Decoding - uva213
Some message encoding schemes require that an encoded message be sent in two parts. The first part,called the header, contains the characters of the message. The second part contains a pattern thatrep...原创 2018-04-01 16:39:41 · 191 阅读 · 0 评论 -
第四章 - uva201 - Squares
A children’s board game consists of a square array of dots that contains lines connecting some of thepairs of adjacent dots. One part of the game requires that the players count the number of squares ...原创 2018-04-06 10:34:57 · 316 阅读 · 0 评论 -
第三章 - 蛇形填数
类似这样填数:10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4思路:向下,左,上,右走每个方向直到无法走时变化方向代码如下:#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int n; ...原创 2018-03-27 20:14:12 · 138 阅读 · 0 评论 -
算法竞赛入门经典第三章 - 学习总结
1.scanf("%s",a);不加&,读入一个字符串,不能读入空格,tab,回车。gets(s);可以识别空格,tab,回车。以上的函数均在末尾加'\0'#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ char a[20...原创 2018-03-28 11:13:22 · 196 阅读 · 0 评论 -
第三章 - Master-Mind Hinds - uva340
MasterMind is a game for two players. One of them, Designer, selects a secret code. The other, Breaker,tries to break it. A code is no more than a row of colored dots. At the beginning of a game, the ...原创 2018-03-29 21:52:12 · 143 阅读 · 0 评论 -
第三章 - Palindromes - uva401
A regular palindrome is a string of numbers or letters that is the same forward as backward. Forexample, the string “ABCDEDCBA” is a palindrome because it is the same when the string is read fromleft ...原创 2018-03-29 22:01:15 · 174 阅读 · 0 评论 -
第五章 - Ducci Sequence - uva1594 - vector,map
A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, · · · , an),the next n-tuple in the sequence is formed by taking the absolute differences of neighboring i...原创 2018-03-18 21:26:42 · 210 阅读 · 0 评论 -
第五章 - STL 初步
STL-C++的标准模板库1.排序与检索sort(a,a+n)-排序lower-bound(a,a+n,x)在排序好的数组中查找大于或等于x的第一个位置#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int a[6]={3,9,7,2,6,5};int...原创 2018-02-08 15:01:15 · 227 阅读 · 0 评论 -
第五章 - uva - 540 - queue
Queues and Priority Queues are data structures which are known to most computer scientists. TheTeam Queue, however, is not so well known, though it occurs often in everyday life. At lunch time thequeu...原创 2018-02-11 22:37:06 · 176 阅读 · 0 评论 -
第五章 - Uva - 101 木块问题(详解) - vector
• move a onto b where a and b are block numbers, puts block a onto block b after returning any blocks that arestacked on top of blocks a and b to their initial positions.• move a over b where a and b ...原创 2018-02-11 22:24:36 · 771 阅读 · 3 评论 -
第五章 - The SetStack Computer - uva - 12096
Background from Wikipedia: “Set theory is abranch of mathematics created principally by theGerman mathematician Georg Cantor at the end ofthe 19th century. Initially controversial, set theoryhas come ...原创 2018-03-12 21:05:45 · 196 阅读 · 0 评论 -
第五章 - 代码对齐 - uva1593 - streamstring的用法
You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) whichis basically a text editor with bells and whistles. You are working on a module that takes a piece ofco...原创 2018-03-15 20:49:14 · 248 阅读 · 1 评论 -
第六章 - UVA816 - Abbott's Revenge - bfs
题目链接题目意思:求从起点到重点的一条最短路。输入:SAMPLE //地图名字,若为"END"则结束3 1 N 3 3 //起点位置,面朝方向,终点位置1 1 WL NR * //地图的描述,以*结尾,意思是,在点(1,1)时,若面朝W,只能左转,若面朝N,则只能右转1 2 WLF NR ER *1 3 NL ER *2 1 SL WR NF *2 2 ...原创 2018-07-27 19:07:42 · 172 阅读 · 0 评论