
UVa
wbb1395
这个作者很懒,什么都没留下…
展开
-
100 The 3n + 1 problem
这题倒没什么难度,有一个坑就是输入的两个数不一定是顺序的,闲着也是闲着,写点uva练练手吧,争取每天一题吧#include <iostream>using namespace std;class CycleNumber{public: void ComputeCycleNumber(int iStart, int iEnd); void OutputResult...原创 2018-08-20 01:01:34 · 123 阅读 · 0 评论 -
101 The Blocks Problem
两块砖位置相同时不进行操作#include <iostream>#include <vector>#include <string>using namespace std;class Blocks{public: void ReadBlocks(); void ComputeBlocks(); void OutputResult();...原创 2018-08-20 11:16:56 · 104 阅读 · 0 评论 -
105 The Skyline Problem
从最左边遍历到最右边,算出每个点的最高点,把横坐标轴放大了一倍,避免连续点的上下起伏#include <iostream>#include <vector>using namespace std;struct Building{ Building(const int& iLeft, const int& iHeight, const in...原创 2018-08-30 17:35:24 · 152 阅读 · 0 评论 -
103 Stacking Boxes
动态规划首先把所有的长方体按大小先排好序,从里到外一个个找,设置一个数组vecBoxes用来存储找到的长方体,数组vecBoxes初始值设为最里面的那个长方体,每遍历一次输入的长方体,就遍历一次数组vecBoxes,如果这个长方体包含数组vecBoxes里的一组长方体的最后一个,先把这个组新的长方体存储到vecAddBoxes遍历完数组vecBoxes以后,从vecAddBoxes里找到最...原创 2018-08-23 14:29:48 · 206 阅读 · 0 评论 -
102 Ecological Bin Packing
没啥内容,穷举就可以了#include <iostream>#include <string>using namespace std;class EcologicalBinPacking{public: void ComputeBottles(const int& iB1b, const int& iB1g, const int&...原创 2018-08-21 10:27:14 · 253 阅读 · 0 评论 -
104 Arbitrage
简单问题就是从一个国家到另一个国家能套汇超过1.01即可选用的算法是Floyd-Warshall,稍作修改,状态转移公式是从一个国家i到另一国家j经过次数k能套汇超过1.01#include <iostream>#include <vector>using namespace std;class Arbitrage{public: void rea...原创 2018-08-30 09:43:22 · 215 阅读 · 0 评论 -
106 Fermat vs. Pythagoras
https://www.cnblogs.com/scau20110726/archive/2013/01/18/2866957.html用反证法都可以证明上文的结论,m_isUsed这个变量一开始我用的是set,验证后发现set在数据量大的时候效率极低,我以为是因为排序导致的,改用了vector,但是结果是一样的,稍稍比set快了一点,最后还是只能用回数组#include <ios...原创 2018-09-04 00:11:54 · 166 阅读 · 0 评论