
杂题
文章平均质量分 77
LB_莫贺延碛
没智商,没毅力,仅仅有一点点运气。
努力向各位前辈大牛学习。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
一道算法笔试题
问题描述 给定参数n(n为正整数),请计算n的阶乘n!末尾所含有“0”的个数。 例如,5!=120,其末尾所含有的“0”的个数为1;10!= 3628800,其末尾所含有的“0”的个数为2;20!= 2432902008176640000,其末尾所含有的“0”的个数为4。 计算公式 这里先给出其计算公式,后面给出推导过程。 令f(x)表示转载 2014-09-04 23:55:23 · 351 阅读 · 0 评论 -
uva 10815
这道题可以map存储字符串,当然使用set更好,因为可以在加入集合时直接进行排序(当然,这道题比较简单,如果是自定义的数据可以重载运算符)。如果使用map就需要另外使用qsort对字符串进行排序。 #include #include #include #include #include #include #include using namespace std; const in原创 2016-07-29 08:35:31 · 371 阅读 · 0 评论 -
uva 10878
呵呵,比较容易想到,只要找几个相应的字符对比一下就能发现规律了。不难 #include #include #include #include #include using namespace std; const string endline = "___________"; string str; bool flag = false; int first, second, res原创 2016-07-28 23:17:31 · 362 阅读 · 0 评论 -
uva 409 poj 1598
uva 409和poj 1598是同一道题。这道题也算是基础题了,主要有两点需要注意 1. A keyword "occurs" in an excuse if and only if it exists in the string in contiguous form and is delimited by the beginning or end of the line or any non原创 2016-07-28 23:12:06 · 796 阅读 · 0 评论 -
uva 10361
一道水水的题。注意的地方就是对字符串顺序处理时每个s串进行正确的分配,注意好边界问题就可以了。另外就是在进行测试用例之前注意好变量的初始化。 code: #include #include #include #include #include using namespace std; int n; char ch; string s[6], strone, strtwo, sec原创 2016-07-23 23:10:14 · 367 阅读 · 0 评论 -
uva 10010
关于搜索的一道简单题。从一个字符块中搜出指定的单词,单词在字符块中的位置可以是水平,垂直,或者对角线共8个方向中的任意一个。 注意:单词的所在的位置一定是一条直线。刚开始我把这道题当做dfs做,结果wa了好多次。 #include #include #include #include #include using namespace std; const int maxn = 5原创 2016-07-23 23:05:24 · 409 阅读 · 0 评论 -
uva 537
一道关于字符串的简单题,主要就是从字符串中找到两个等号的位置后,进行分析便可。 另外注意前缀所代表的数值大小(k, M, m) #include #include #include #include #include using namespace std; int kasenum; string str; double power, volt, curr; int pos[3]原创 2016-07-23 23:00:15 · 341 阅读 · 0 评论 -
uva 401
这几天老板有事出去开会了, 所以有了点时间能够看看别的内容。 算法的东西好长时间没打了, 都是在看有关开发和数理统计的内容。于是打算开个新坑。大部分题目是入门经典中的 uva 401 这道题比较简单, 在回文字符串的概念上增加了一个镜像对称的概念。 code: #include #include #include #include #include using namespa原创 2016-07-23 22:54:42 · 389 阅读 · 0 评论 -
Summary for leetcode 2Sum, 3Sum, 4Sum, K Sum
前言: 做过leetcode的人都知道, 里面有2sum, 3sum(closest), 4sum等问题, 这些也是面试里面经典的问题, 考察是否能够合理利用排序这个性质, 一步一步得到高效的算法. 经过总结, 本人觉得这些问题都可以使用一个通用的K sum求和问题加以概括消化, 这里我们先直接给出K Sum的问题描述和算法(递归解法), 然后将这个一般性的方法套用到具体的K, 比如leet转载 2014-11-19 20:21:26 · 664 阅读 · 0 评论 -
uva 101
#include #include #include using namespace std; const int maxn = 25 + 10; int place[maxn]; int stack[maxn][maxn]; int top[maxn]; int number; char oper[maxn], prep[maxn]; int a, b; void init_pla原创 2016-09-30 17:22:23 · 415 阅读 · 0 评论