- 博客(65)
- 资源 (1)
- 收藏
- 关注
原创 BZOJ 1798 维护序列 (多校连萌,对线段树进行加乘混合操作)
题目地址:http://www.lydsy.com/JudgeOnline/problem.php?id=1798思路:对一段区间的数进行加乘混合操作,思路还是挺巧的,举个例子sum[rt]为一段区间的和,对区间+x再乘以p(sum[rt]+x)*p=sum[rt]*p+x*p可以写成对这个区间乘以p,每次乘的时候对a[rt]乘p,这个思路很巧AC代码:#include #inc
2016-03-31 15:31:12 520
原创 nyist 201 作业题(最长上升子序列和最长下降子序列)
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=201思路:注意有可能单调递增和单调递减AC代码:#include #include #include #include #include #include #include #include #include #include #include const
2016-03-30 20:01:37 286
原创 nyist 1204 魔法少女
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=1204思路:每次瞬移的时候至少再往上爬一层,看到这句话直接就忽略了,不可能枚举从哪开始不使用魔法的吧,结果dp[i]从dp[i-1]转移即可,这个思路挺巧妙的,还有就是刚开始的特判也挺巧妙的AC代码:#include #include #include #include
2016-03-30 19:00:25 412
原创 nyist 1070 诡异的电梯【Ⅰ】(比较好的DP)
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=1070思路:刚开始想着求每层电梯停或者不停的状态,wrong了,后来想明白这种想法是错的如5 停 不停4 不停 停3 停 不停2 不停 停1 停 不停如果在第一层和第四层停最少(例
2016-03-30 18:21:02 585
原创 Light oj 1044 - Palindrome Partitioning (多校连萌,求最少回文子串的个数)
题目地址:http://lightoj.com/volume_showproblem.php?problem=1044题意:把一个字符串分成几个子串,并且每个子串是回文子串,求最少得分成几个子串思路:枚举起点和终点是O(n^2),再加上判断回文O(n^3),做一下记忆化时间会少到O(n^2)AC代码:#include #include #include #include #
2016-03-29 17:17:05 417
原创 POJ 2828 Buy Tickets(多校连萌,线段树模拟插入)
题目地址:http://poj.org/problem?id=2828题意:给一个队列,第一个数是插在哪个位置上,第二个数这个人的标号,问最后的队列是什么样思路:用线段树倒着插入即可AC代码:#include #include #include #include #include #include #include #include #include #inclu
2016-03-29 16:09:27 290
原创 ZOJ 2797 106 miles to Chicago(多校连萌,用最短路径求概率问题)
题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1797思路:因为没有重边就不用判断了AC代码:#include #include #include #include #include #include #include #include #include #include #inclu
2016-03-29 10:56:32 617
原创 ZOJ 1372 Networking(Prim求最小生成树)
题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=372思路:一般需要考虑的就是能否组成最小生成树和2点之间选取最短边AC代码:#include #include #include #include #include #include #include #include #include #
2016-03-29 09:22:48 271
原创 HDU 2082 F(N)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2802思路:直接暴力模拟不行,打个表找找循环节找循环节程序#include #include #include #include #include #include #include #include #include #include #include const i
2016-03-27 18:21:45 272
原创 HDU 3177 Crixalis's Equipment(很巧妙的贪心)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3177思路:刚开始的想法是挪的时候占体积大的先进,如果挪的体积相同,则放的时候体积小的先进,结果wrong了,举一个反例40 220 302 19大神地址:http://blog.csdn.net/hjd_love_zzt/article/details/9877115AC代码:
2016-03-27 17:41:51 262
原创 nyist 740 “炫舞家“ST
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=740思路:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f
2016-03-27 15:59:17 298
原创 HDU 1059 Dividing(多重背包)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1059思路:简单多重背包,按照题目数据开的数组,结果RE了,果断开大,直接过了AC代码:#include #include #include #include #include #include #include #include #include #include #i
2016-03-27 10:52:08 281
原创 nyist 61 传纸条(一)(双线程DP)
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=61思路:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;
2016-03-27 10:17:57 277
原创 HDU 1080 Human Gene Functions(带权值的最长公共子序列)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1080思路:最长公共子序列AC代码:#include #include #include #include #include using namespace std;int main(){ map map1; map1['A'] = 0; map1['C
2016-03-25 16:31:45 402
原创 HDU 1224 Free DIY Tour(DP求最短路)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1224思路:这道题说到底就是用DP求最短路,之所以能用DP,是因为题目中说了,飞机只能从标号低的城市到标号高的城市
2016-03-25 16:26:32 537
原创 HDU 1300 Pearls
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1300思路:简单DPAC代码:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3
2016-03-25 14:40:56 221
原创 HDU 1502 Regular Words(大数+dp)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1502思路:dp[3*n][n][n][n],第一维是长度,第2.3.4维是a,b,c的个数,写出的转移方程不是超Int就是超内存错误代码1:#include #include #include #include #include #include #include #incl
2016-03-25 11:39:28 328
原创 nyist 16 矩形嵌套(最长上升子序列变形)
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=16思路:放矩形的时候,正着放一次,倒着放一次,正着放肯定不会套着倒着放AC代码:#include #include #include #include #include #include #include #include #include #include
2016-03-25 09:51:30 224
原创 nyist 252 01串
题目地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=252思路:第一维表示长度,第二维表示目前最后一位是0还是1AC代码:#include #include #include #include #include #include #include #include #include #include #incl
2016-03-25 09:23:42 260
原创 POJ 1832 Stripies(贪心)
题目地址:http://poj.org/problem?id=1862思路:每次选最大的2个值乘AC代码:错误代码:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f
2016-03-23 14:34:57 428
转载 扩展欧几里得算法
原文地址:http://blog.csdn.net/zhjchengfeng5/article/details/7786595 扩展欧几里德算法 谁是欧几里德?自己百度去 先介绍什么叫做欧几里德算法 有两个数 a b,现在,我们要求 a b 的最大公约数,怎么求?枚举他们的因子?不现实,当 a b 很大的时候,枚举显得那么的naïve ,那
2016-03-22 21:07:03 289
转载 中国剩余定理
原文地址:http://www.cnblogs.com/walker01/archive/2010/01/23/1654880.htmlPOJ1006: 中国剩余定理的完美演绎问题描述 人自出生起就有体力,情感和智力三个生理周期,分别为23,28和33天。一个周期内有一天为峰值,在这一天,人在对应的方面(体力,情感或智力)表现最好。通常这三个周期的峰值不会是
2016-03-22 20:34:43 397
原创 Light Oj 1319 - Monkey Tradition(多校联盟3,中国剩余定理)
题目地址:http://lightoj.com/volume_showproblem.php?problem=1319思路:暴力直接超时,用中国剩余定理AC代码:超时代码:#include #include #include #include #include #include #include #include #include #include #i
2016-03-22 20:00:03 378
原创 UESTC 1012 Ladygod (多校联盟3)
题目地址:http://acm.uestc.edu.cn/#/problem/show/1012思路:4位相加最多只会产生5位数,进制越低,位数越长AC代码:#include #include #include #include #include #include #include #include #include #include #include const
2016-03-22 18:49:52 307
原创 NBUT 1647 (多校连萌3)
题目地址:https://ac.2333.moe/Problem/view.xhtml?id=1647AC代码:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f3f3f3f;//
2016-03-22 18:18:42 392
原创 HDU 5645 DZY Loves Balls
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5645思路:简单模拟AC代码:#include #include #include #include #include #include #include #include #include #include #include const int inf = 0x3f
2016-03-22 18:14:22 359
原创 UESTC 1271 Search gold (DP,多校联盟3)
题目地址:http://acm.uestc.edu.cn/#/problem/show/1271思路:有一个坑就是当他身上没有钱的时候会死掉AC代码:#include #include #include #include #include #include #include #include #include #include #include const in
2016-03-22 18:11:42 365
原创 埃拉托色尼筛选法求素数
算法的思想很简单,找一张表,先把1划掉,然后在把2的倍数划掉,接着找下一个没有被划掉的数,是3,接着把3的倍数划掉,接着找下一个没有被划掉的数,是5,接着把5的倍数划掉,接着找下一个没有被划掉的数,依次类推#include #include #include #include #include #include #include #include #include #incl
2016-03-19 08:09:26 790
原创 POJ 3468 A Simple Problem with Integers(线段树)
题目地址:http://poj.org/problem?id=3468思路:updata()区间增减,query()区间求和,会超int用long longAC代码:#include #include #include #include #include #include #include #include #include #include #include
2016-03-17 16:49:28 295
原创 HDU 1698 Just a Hook(线段树)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1698思路:updata()区间替换,query()区间求和先上3篇博客 1:http://blog.sina.com.cn/s/blog_a2dce6b30101l8bi.html 2:http://www.tuicool.com/articles/j6N3eaz 3:http://w
2016-03-17 15:16:11 277
原创 HDU 2795 Billboard(线段树)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2795思路:用数的最下面的节点表示一层(即到最下面一层有n个节点就可以了),并且用这个节点的左或右的区间范围表示层数(子节点的左区间和右区间其实是相同的),这个思路很巧,我也是看了别人的题解才懂的AC代码:
2016-03-17 11:17:47 289
原创 HDU 1754 I Hate It(区间最值)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1754思路:updata()单点替换,query()区间最值AC代码:#include #include #include #include #include #include #include #include #include #include #include
2016-03-16 21:02:40 284
原创 HDU 1559 最大子矩阵
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1559思路:和那个二维的最大子矩阵有点类似AC代码:#include #include #include #include #include #include #include #include #include #include #include const int
2016-03-13 17:11:29 428
原创 2012年第三届蓝桥杯试题(C/C++本科B组)
1 假设有两种微生物 X 和 Y X出生后每隔3分钟分裂一次(数目加倍),Y出生后每隔2分钟分裂一次(数目加倍)。 一个新出生的X,半分钟之后吃掉1个Y,并且,从此开始,每隔1分钟吃1个Y。 现在已知有新出生的 X=10, Y=89,求60分钟后Y的数目。 如果X=10,Y=90 呢? 本
2016-03-13 17:03:46 531
原创 2013年第四届蓝桥杯试题(C/C++本科B组)
1大数学家高斯有个好习惯:无论如何都要记日记。 他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210 后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢? 高斯出生于:1777年4月30日。
2016-03-13 11:39:02 425
原创 HDU 5640 King's Cake
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5640思路:和求最大公约数有点类似AC代码:#include #include #include #include #include #include #include #include #include #include #include const int inf
2016-03-12 21:53:02 304
转载 SPFA 算法详解( 强大图解,不会都难!)
原文链接:http://lib.csdn.net/article/datastructure/10344适用范围:给定的图存在负权边,这时类似Dijkstra等算法便没有了用武之地,而Bellman-Ford算法的复杂度又过高,SPFA算法便派上用场了。 我们约定有向加权图G不存在负权回路,即最短路径一定存在。当然,我们可以在执行该算法前做一次拓扑排序,以判断是否存在负权回路,但这不是我们讨论...
2016-03-11 19:40:57 2609 4
原创 2014年第五届蓝桥杯试题(C/C++本科B组)
题目地址:http://wenku.baidu.com/link?url=w2flm9and7b1cg_gPOHAi8N-TfFxeje0FVyHab4PsCpegJ9SapcDTvb22sRiBlBKmwf8_vKywFPMroQwuM-jvBxWBeyJYv8mmtyRG5HrY3C有些题实在是粘贴不了,自己去看吧1.标题:啤酒和饮料 啤酒每罐2.3元,饮料每罐1.9元。
2016-03-11 17:46:16 3456
原创 HDU 2604 Queuing(矩阵快速幂)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2604思路:刚开始写DP错了,看别人的题解改了还是错,直接学快速幂A了,学了一招,第二位有2维时,可以开2个一维数组,比较容易理解AC代码:错误代码:#include #include #include #include #include #include #incl
2016-03-11 11:28:25 420
原创 2015年第六届蓝桥杯试题(C/C++本科B组)
1有些人很迷信数字,比如带“4”的数字,认为和“死”谐音,就觉得不吉利。虽然这些说法纯属无稽之谈,但有时还要迎合大众的需求。某抽奖活动的奖券号码是5位数(10-99),要求其中不要出现带“4”的号码,主办单位请你计算一下,如果任何两张奖券不重号,最多可发出奖券多少张。请提交该数字(一个整数),不要写任何多余的内容或说明性文字。答案:第一位不取0和4,剩下四位不取4,
2016-03-09 21:39:04 10273
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人