![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
嘿嘿嘿唔哈哈
恰似飞鸿踏雪泥
展开
-
2016-2017 acm-icpc neerc moscow subregional contest l题题解
题目大意:就是在不同时间放入和取出小球。算出每个小球生存时间的期望如果直接用递归算会超时。。。这里可以算出生存时间是是一个线性函数。展开之后就可以发现有O(n)的方法解决。代码:#include #include #include #include #include #include #define REP(i,a,b) for(int i=a;i<=b;i+原创 2016-11-02 18:30:15 · 1457 阅读 · 0 评论 -
ACM-ICPC 2014 WF problem a
ACM-ICPC 2014 WF problem a构造,需要有3,4,5,6,7的特例,然后n就可以转化为n-4的解6,7 的解凑了好久,然后3 也凑了好久,最后编程穷举算出来。。。直接上代码吧#include <iostream>using namespace std;void out(int a, int b){ cout << a << " to " << b << endl;原创 2017-05-21 16:16:37 · 534 阅读 · 0 评论 -
ACM-ICPC 2014 WF --UVALive 6770 - Baggage
感觉构造,需要有3,4,5,6,7的特例,然后n就可以转化为n-4的解原创 2018-03-16 21:12:48 · 451 阅读 · 0 评论 -
Median of Two Sorted Arrays(Leetcode 4)| 时间复杂度一定大于空间复杂度?| 题解
近日刷到Leetcode 4题目。感觉这个题目作为标记hard的题目,还是很有意思的。题目如下:There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity shoul...原创 2018-03-16 21:31:49 · 304 阅读 · 0 评论 -
快速排序时间复杂度 简明分析(平均/最坏/with high probabilty)
最近研究随机算法,发现快速排序作为一种入门算法,分析其时间复杂度还是很有趣的。首先,证明其最坏时间复杂度为 是很容易的。证明其平均时间复杂度的期望是也有很多不同方式。这里介绍两种简单的方式。需要说明的是,这里的快排是随机化的排序算法。因此对于任意输入,其期望的时间复杂度都是相同的。首先是比较容易的方式。我们假设算法的输入是有序序列<a1,a2,a3,a4...,an>的一个...原创 2019-02-05 14:23:08 · 8943 阅读 · 0 评论