随笔分类 - OJ UVA
摘要:"Ray, Pass me the dishes!" UVA - 1400 题意就是线段树区间子段最大和,线段树区间合并,但是这道题还要求输出最大和的子段的左右端点。要求字典序最小,要求左右端点尽量靠左。 比如: 3 3 3 -9 3 3 3 输出的是1 3,而不是1 7 3 3 3 -9 3 3
阅读全文
摘要:Tree UVA - 548 题意就是多次读入两个序列,第一个是中序遍历的,第二个是后序遍历的。还原二叉树,然后从根节点走到叶子节点,找路径权值和最小的,如果有相同权值的就找叶子节点权值最小的。 最后输出来叶子节点。 一开始写的时候是用gets读入的,报CE, 要用fgets写,关于fgets(),
阅读全文
摘要:Power of Matrix UVA - 11149 代码: 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <algorithm> 5 using namespace std; 6 #define
阅读全文
摘要:10382 - Watering Grass Time limit: 3.000 seconds n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprin
阅读全文
摘要:Building designing Time limit: 3.000 seconds An architect wants to design a very high building. The building will consist of some floors, and each floor
阅读全文
摘要:Hello World! Time limit: 1.000 seconds When you first made the computer to print the sentence “Hello World!”, you felt so happy, not knowing how comple
阅读全文
摘要:11461 - Square Numbers Time limit: 1.000 seconds A square number is an integer number whose square root is also an integer. For example 1, 4, 81 are s
阅读全文
摘要:12050 - Palindrome Numbers Time limit: 3.000 seconds A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example,
阅读全文
摘要:10339 - Watching Watches Time limit: 3.000 seconds It has been said that a watch that is stopped keeps better time than one that loses 1 second per da
阅读全文
摘要:二分查找 二分查找又称折半查找,优点是比较次数少,查找速度快,平均性能好;其缺点是要求待查表为有序表,且插入删除困难。因此,折半查找方法适用于不经常变动而查找频繁的有序列表。首先,假设表中元素是按升序排列,将表中间位置记录的关键字与查找关键字比较,如果两者相等,则查找成功;否则利用中间位置记录将表分
阅读全文