摘要: 原题链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1091 思路分析:通过读题不难发现这是一道涉及贪心算法的题,刚开始上手做也是摸不着头脑。首先把所有的线段按起点由小到大进行... 阅读全文
posted @ 2018-08-02 16:47 laugh12321 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://poj.org/problem?id=1664 思路:苹果m个,盘子n个。假设 f ( m , n ) 代表 m 个苹果,n个盘子有 f ( m , n ) 种放法。 根据 n 和 m 的关系可以进一步分析: 特殊的 n = 1 |... 阅读全文
posted @ 2018-08-01 17:43 laugh12321 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1312 题目大意:有一间矩形房屋,地上铺了红、黑两种颜色的方形瓷砖。你站在其中一块黑色的瓷砖上,只能向相邻的黑色瓷砖移动,计算你总共能够到达多少块黑色的瓷砖。 要求... 阅读全文
posted @ 2018-08-01 15:21 laugh12321 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1576 分析:等式枚举法,由题意可得:, ,代入 , 得:,把变量 合在一起得: ;即满足 为 倍数,因为 ,所以解时唯一的。 使用... 阅读全文
posted @ 2018-07-24 20:55 laugh12321 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 原题链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1013 首先得考虑到时间复杂度问题,由于题目中(0 typedef long long ll;const ll mod... 阅读全文
posted @ 2018-07-24 20:15 laugh12321 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 原题链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756 这道题用STL解答还是比较简单的,下面就给大家... 阅读全文
posted @ 2018-07-22 10:45 laugh12321 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 原题链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=92 整体思路如下:先建立一个 m... 阅读全文
posted @ 2018-07-22 10:26 laugh12321 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 这道题是超级水的,在博客上看有的人把这道题写的很麻烦。 用 Python 的话是超级的好写,这里就奉上 C/C++ 的AC。 代码如下: #include #include using namespace std;int main(void) { long l... 阅读全文
posted @ 2018-07-21 16:06 laugh12321 阅读(16) 评论(0) 推荐(0) 编辑
摘要: C++ STL中最基本以及最常用的类或容器无非就是以下几个: stringvectorsetlistmap下面就依次介绍它们,并给出一些最常见的最实用的使用方法,做到快速入门。 string 首先看看我们C语言一般怎么使用字符串的 char* s1 = "He... 阅读全文
posted @ 2018-07-21 15:54 laugh12321 阅读(19) 评论(0) 推荐(0) 编辑
摘要: 不重复数字 题目: 给出N个数,要求把其中重复的去掉,只保留第一次出现的数。例如,给出的数 为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 ... 阅读全文
posted @ 2018-07-21 11:11 laugh12321 阅读(31) 评论(0) 推荐(0) 编辑