摘要:
Problem Description话说,经过了漫长的一个多月,小明已经成长了许多,所以他改了一个名字叫“大明”。这时他已经不是那个只会做100以内加法的那个“小明”了,现在他甚至会任意长度的正小数的加法。现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。Input本题目包含多组测试数据,请处理到文件结束。每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。Output请在一行里面输出输出A+B的值,请输出最简形式。详细要求请见Sample Output。Sample Input1.1 2.91.1111111111 2.34443233431 1.1Sample 阅读全文
摘要:
题目:http://poj.org/problem?id=2442题目大意: 给你n*m的矩阵,然后每行取一个元素,组成一个包含n个元素的序列,一共有n^m种序列,让你求出序列和最小的前n个序列的序列和。解题步骤:1.将第一序列读入data1向量中,并按升序排序。2.将数据读入data2向量中,并按升序排序。将data2[0] + data1[i] ( 0<=i<=n-1)读入dataq向量中用make_heap对dataq建堆。然后data2[1] + data1[i] (0<=i<=n-1),如果data2[1] + data1[i]比堆dataq的顶点大,则退出, 阅读全文
摘要:
题目:http://poj.org/problem?id=2051题目大意: 这道题就是个最小堆,把最先到达的query输出query编号,然后继续排队等待同样的时间,要是某几个请求同时到达的话,就要按照编号从小到大的输出。思路: 先定义一个结构体,里面包含 query的 id 和 time,然后将query放进优先队列里,变可以轻松解决问题。AC代码: 1 #include<cstdio> 2 #include<iostream> 3 #include<queue> 4 using namespace std; 5 6 struct Info 7 { 8 阅读全文
摘要:
DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needsN(1 ≤N≤ 20,000) planks of wood, each having some integer lengthLi(1 ≤Li≤ 50,000) units. He then purchases a single long board just long enough to saw into theNplanks (i 阅读全文
摘要:
概念有带权图G, 对于图中每条边e[i], 都有benifit[i](收入)和cost[i](花费), 我们要求的是一棵生成树T, 它使得 ∑(benifit[i]) / ∑(cost[i]), i∈T 最大(或最小).这显然是一个具有现实意义的问题.解法之一 0-1分数规划设x[i]等于1或0, 表示边e[i]是否属于生成树.则我们所求的比率 r = ∑(benifit[i] * x[i]) / ∑(cost[i] * x[i]), 0≤i<m .为了使 r 最大, 设计一个子问题---> 让 z = ∑(benifit[i] * x[i]) - l * ∑(cost[i] * 阅读全文
摘要:
DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some highways so that it will be possible to drive between any pair of 阅读全文
摘要:
DescriptionFarmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course.Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. T 阅读全文
摘要:
DescriptionThe Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensive to maintain. The Council of Elders must choose t 阅读全文