上一页 1 2 3 4 5 6 7 8 9 ··· 17 下一页
摘要: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1242 1 #include 2 typedef long long ll; 3 const int mod = 1e9+9; 4 struct Mat 5 { 6 ... 阅读全文
posted @ 2015-06-21 16:42 NowAndForever 阅读(247) 评论(0) 推荐(0) 编辑
摘要: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1113这个题因为m比较大,所以不能递归求解,需要换成循环的形式. 1 #include 2 typedef long long ll; 3 const int mod = ... 阅读全文
posted @ 2015-06-21 16:08 NowAndForever 阅读(183) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1151在一个城市里有n个地点和k条道路,道路都是单向的,并且不存在环.(DAG)现在伞兵需要去n个地点视察,伞兵只能沿着路的方向走,问最少需要多少伞兵。DAG的最小路径覆盖是指找最小数目的互相不相交的有向路径,满足... 阅读全文
posted @ 2015-06-20 18:47 NowAndForever 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 你住在村庄A,每天需要过很多条河到另一个村庄B上班,B在A的右边,所有的河都在A,B之间,幸运的是每条船上都有自由移动的自动船,因此只要到达河左岸然后等船过来,在右岸下船,上船之后船的速度不变.现在问从A到B的期望时间是多少,假设在出发时船的位置都是随机分布.人在 陆地上行走的速度为1.根据数学期望... 阅读全文
posted @ 2015-06-20 14:11 NowAndForever 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 设事件B为一共有r个人买了东西,设事件Ai为第i个人买了东西。 那么这个题目实际上就是求P(Ai|B),而P(Ai|B)=P(AiB)/P(B),其中P(AiB)表示事件Ai与事件B同时发生的概率,同时总状态并不多,因此我们可以枚举买东西的状态预处理出P(AiB)和P(B),再代入计算即可。枚举就... 阅读全文
posted @ 2015-06-20 13:46 NowAndForever 阅读(169) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3071参考博客:http://blog.csdn.net/libin56842/article/details/10054725不得不说 概率dp很难理解!!这题最主要的就是判断是否相邻,可以用位运算找规律求出.p,q得到的是每一轮0-m-1个球... 阅读全文
posted @ 2015-06-19 20:31 NowAndForever 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 常规思路:定义 dp[i]:=以a[i]为末尾元素的最长上升子序列的长度,以a[i]结尾的上升序列是:只包含a[i]的序列,在满足j 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include ... 阅读全文
posted @ 2015-06-18 20:18 NowAndForever 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 归并排序:时间复杂度为O(nlogn) 这是该算法中最好、最坏和平均的时间性能。空间复杂度为 O(n)归并排序比较占用内存,但却是一种效率高且稳定的算法。速度仅次于快速排序,为稳定排序算法,一般用于对总体无序,但是各子项相对有序的数列。具体思路是,在归并的过程中计算每个小区间的逆序对数,进而计算出大... 阅读全文
posted @ 2015-06-18 18:47 NowAndForever 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #in... 阅读全文
posted @ 2015-06-16 21:52 NowAndForever 阅读(316) 评论(0) 推荐(0) 编辑
摘要: http://acm.fzu.edu.cn/problem.php?pid=2171成段增减,区间求和.add累加更新的次数。#include #include #include #include #include #include #include #include #include #inclu... 阅读全文
posted @ 2015-06-16 18:18 NowAndForever 阅读(139) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 17 下一页