随笔分类 - 算法练习C++
做过的一些题目,使用C++的写程序
摘要:Description A set of n<tex2html_verbatim_mark> 1-dimensional items have to be packed in identical bins. All bins have exactly the same length l<tex2ht
阅读全文
摘要:UVA10382 :http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=21419 只能说这道题和D题是一模一样的,不过要进行转化,这道题有一道坑,方法一需要使用scanf()输入,还需判断输入的正确性,即scanf()==3。。。
阅读全文
摘要:原题 UVA10020 :http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19688 经典的贪心问题,区间上贪心当然是右区间越右越好了,当然做区间要小于等于当前待覆盖的位置,我们可以用一个变量begin代表当前待覆盖的区间的左值
阅读全文
摘要:Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6639 Accepted Submission(s): 2514 Problem Descrip
阅读全文
摘要:恢复内容开始 Description Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by
阅读全文
摘要:原题poj 2299:http://poj.org/problem?id=2299 题意,给你一个数组,去统计它们的逆序数,由于题目中说道数组最长可达五十万,那么O(n^2)的排序算法就不要再想了,归并排序~~~ 这里列出归并的解法: #include <iostream> #include <cs
阅读全文
摘要:题意 给出如图案例,要你从某一点开始走,一直走到极限(即无法再进行扩展),这时你走过的点会连成一个数,不同的走法当然会有不同的数,要求是输出最大的数(注意每个方块走过一次就不能再走) 思路 •1.枚举所有的点作为起点,然后求从这个点所能得到的最大数 •2.然后是使用DFS求从某一点可以到达的最大数
阅读全文
摘要:Description Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an ordering on the elements in V, then the bandwidth of a
阅读全文
摘要:Starting with x and repeatedly multiplying by x, we can compute x31 with thirty multiplications: The operation of squaring can appreciably shorten the
阅读全文
摘要:Description Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are calledequi
阅读全文
摘要:通过暴力或者dfs的方法可以很容易地得到n个数的全排列,可生成可重集的呢,例如给出一个数组a[],要求输出这个数组的全排列,与普通的求全排列不同,数组中很可能存在重复的数,所以方法都需要改一改: DFS #include"iostream" #include"cstring" #include"cs
阅读全文
摘要:枚举,由已知条件推得y大于k,小于等于2K AC代码: #include"iostream"#include"cstring"using namespace std;const int maxn=20002;int a[maxn];int b[maxn];int main(){ int i,y; i
阅读全文
摘要:Description A ring is composed of n (even number) circles as shown in diagram. Put natural numbers into each circle separately, and the sum of numbers
阅读全文
摘要:Given a sequence of integers S = {S1, S2, ..., Sn}, you shoulddetermine what is the value of the maximum positive product involving consecutive terms
阅读全文
摘要:Description Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the
阅读全文
摘要:Description In this problem, you are given an integer number s. You can transform any integer number A to another integer number B by adding x to A. T
阅读全文
摘要:Description You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend o
阅读全文
摘要:You have just finished a compiler design homework question where you had to find the parse tree of an expression. Unfortunately you left your assignme
阅读全文
摘要:In a country, there are a number of cities. Each pair of city is connected by a highway, bi-directional of course. A road-inspector’s task is to trave
阅读全文
摘要:Description The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 slidin
阅读全文