上一页 1 ··· 70 71 72 73 74 75 76 77 78 ··· 136 下一页
摘要: 自己按照stl实现了一个: http://www.cplusplus.com/reference/algorithm/binary_search/ 这里有个注释,如何判断两个元素相同: Two elements, a and bare considered equivalent if (!(a bool binary_search (ForwardIterator first, For... 阅读全文
posted @ 2014-03-24 14:59 katago 阅读(228) 评论(0) 推荐(0)
摘要: // UVa442 Matrix Chain Multiplication // 题意:输入n个矩阵的维度和一些矩阵链乘表达式,输出乘法的次数。假定A和m*n的,B是n*p的,那么AB是m*p的,乘法次数为m*n*p // 算法:用一个栈。遇到字母时入栈,右括号时出栈并计算,然后结果入栈。因为输入保证合法,括号无序入栈 #include#include#include#in... 阅读全文
posted @ 2014-03-21 13:36 katago 阅读(943) 评论(0) 推荐(0)
摘要: 嵌套玩具, 要求外层玩具的尺寸比内层玩具尺寸的和要大. 每一个玩具由一个负数与相应的正数表示, 在这两数之间的部分即为此玩具内部的玩具. 要求判断一串输出的数字是否能组成一个合法的玩具. 一个合法的玩具: 1. 数字代表了 toy 的尺寸大小. 2. 外层的 size 必须 > 内层 size 的和, 不能是 >=. 3. 每次必须是负正对一起出现. 思路: 用一个... 阅读全文
posted @ 2014-03-21 13:27 katago 阅读(301) 评论(0) 推荐(0)
摘要: // UVa673 Parentheses Balance // 题意:输入一个包含()和[]的括号序列,判断是否合法。 // 具体递归定义如下:1.空串合法;2.如果A和B都合法,则AB合法;3.如果A合法则(A)和[A]都合法。 // 算法:用一个栈。注意输入可能有空串 #include#include#include#include#include#includ... 阅读全文
posted @ 2014-03-20 14:52 katago 阅读(773) 评论(0) 推荐(0)
摘要: //这个算法用到了“相对位置”的思想,并且就本题而言还有一个很重要的结论就是,假设 //移动了k个元素,那么这k个元素一定是最后结果的那个序列的前k个元素,而且易知, //越先移动的元素一定会越被压在移动的元素的底部 首先找到需要移动的字符串,方法如下:以初始序列为准,设初始序列下标为i, 目的序列下标为j, 从n-1开始,如果两下标对应的字符串相等,下标同时减一,否则仅初始序列下标... 阅读全文
posted @ 2014-03-20 10:24 katago 阅读(239) 评论(0) 推荐(0)
摘要: 题意:给出n条线段,以米的单位给出,小数点后两位(精确到厘米),要你对这些线段裁剪,裁剪出m条等长的线段,并且让这些线段尽可能长另外线段的长度不能小于1厘米,如果筹不够m条,输出0.00 #include#include#include#include#includeusing namespace std;const int maxn=10010;double num[maxn];doub... 阅读全文
posted @ 2014-03-18 15:46 katago 阅读(238) 评论(0) 推荐(0)
摘要: fengyun@fengyun-server:~/learn/acm/poj$ cat 1979.cpp #include #include #include #include #include #include//istringstream #include #include using namespace std; char map... 阅读全文
posted @ 2013-11-11 11:34 katago 阅读(448) 评论(0) 推荐(0)
摘要: 学到两个: //ignore \n cin.ignore(); //ignore a line cin.ignore(1024, '\n'); #include#include#include#include#include#include//uva 10033 Problem G: Interpreter#define ONLINE_JUDGEusing namespac... 阅读全文
posted @ 2013-10-30 15:18 katago 阅读(561) 评论(0) 推荐(0)
摘要: #include #include #include #include #include #include #include using namespace std; int m; int n; //bmp[y][x] char bmp[251][251]; void swap_if_bigger(int& x, int& y) ... 阅读全文
posted @ 2013-10-30 11:19 katago 阅读(468) 评论(0) 推荐(0)
摘要: #include #include #include #include using namespace std;string numbers[5][10]={ " - ", " ", " - ", " - ", " ", " - ", " - ", " - ", " - ", ... 阅读全文
posted @ 2013-10-30 11:17 katago 阅读(465) 评论(0) 推荐(0)
上一页 1 ··· 70 71 72 73 74 75 76 77 78 ··· 136 下一页