![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 69
wangyuquan
这个作者很懒,什么都没留下…
展开
-
priority_queue优先级队列
转载地址:http://blog.csdn.net/morewindows/article/details/6976468priority_queue 优先级队列是一个拥有权值概念的单向队列queue,在这个队列中,所有元素是按优先级排列的(也可以认为queue是个按进入队列的先后做为优先级的优先级队列——先进入队列的元素优先权要高于后进入队列的元素)。在计算机操作系统中,优先级队列的使用转载 2013-04-01 12:06:48 · 974 阅读 · 0 评论 -
topcoder srm608 div1 300分题
题目:Problem Statement TopCoder admin mystic_tc is sitting in front of a table. He found N sealed boxes of candies on the table.He is not sure how many candies each box contai原创 2014-02-08 19:16:06 · 1600 阅读 · 0 评论 -
topcoder srm609 div1
总的来说这次的div1 前两题都比以前简单,我这种不碰500的都开始做500分的题了= =250pt题目:Problem Statement Magical Girl Illy uses "magical strings" to cast spells. For her, a string X is magical if and only if t原创 2014-02-16 14:07:21 · 3724 阅读 · 1 评论 -
Codeforces Round #240 (Div. 2)
500pt:A. Mashmokh and Lightstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMashmokh works in a facto原创 2014-04-07 22:00:08 · 1678 阅读 · 0 评论 -
关于C++ 牛人推荐的好书(转载)
首先肯定要读一读Bjarne Stroustrup的The Design and Evolution of C++,了解一下这个语言的历史。接下来就可以看别的书了,但要不停地回头看这本书,看到你不断地学到的新技术是怎么样一点点地被接纳到这个语言中去的。第一本书因人而异,基础好一些的,可以看Stanley B. Lippman的C++ Primer,这本书非常地巨大,你打星号转载 2014-04-24 20:51:48 · 884 阅读 · 0 评论 -
C++何时会帮忙合成default constructor
最近在看《深度探索C++对象模型》,学到了很多东西。。。C++新手一般有两个常见的误解:1.任何class如果没有定义default constructor,就会被合成出一个来。2.编译器合成出来的default constructor会显示设定“class 内每一个data member的默认值”注意:以上两个说法都是错误的!编译器只会在以下4种情况,并且class自原创 2014-06-04 22:18:38 · 1626 阅读 · 0 评论 -
Codeforces Round #261 (Div. 2)
A,B两题就不写了。。。C. Pashmak and Busestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Pashmak原创 2014-08-16 18:41:13 · 1104 阅读 · 0 评论 -
Codeforces Round #277(Div. 2)
A题:http://codeforces.com/contest/486/problem/A分析:分析下奇偶就出来结果了代码:#include #include #include #include #include #include #include #include #include #include #include #include #include原创 2014-11-12 23:11:16 · 931 阅读 · 0 评论 -
指针的各种变形
说起来以前好像也没太过深入的了解指针,仅仅停留在能使用的阶段,所以当出现int *(*f[])()这种表达式的时候,我也基本上就是跪了。。。最近在看《C和指针》这本书,不得不说,它讲的还是很透彻的,故在博客中记录一下,以后也方便复习~判断指针的方法是把申明的那段语句看成一个表达式,然后再一步一步确定。看例子很好懂int f毫无疑问,f是一个整形变量int *f这一般也没问题原创 2014-11-19 22:19:21 · 1072 阅读 · 0 评论 -
对智能指针的一些理解
c++本身不提供自动内存回收机制,所以每次我们有new一个对象或者数组,我们都是时时刻刻提醒自己要记得去delete new出来的对象,那样岂不是非常烦人?而且就算你记得在析构函数中delete new出来的对象,也同样会造成很多问题,比如一个class里面有个指针,初始化的时候new了一块内存,然后class 有个对象a,再通过class b=a复制一份a,这样其实两个对象分别有一个指针指向ne原创 2014-11-26 16:37:46 · 1408 阅读 · 0 评论 -
topcoder srm607 div2
250pt:题目:Problem Statement Andrew drew a bunch of points on a sheet of graph paper. You are given the coordinates of these points in two vector s:X and Y. That is, for eac原创 2014-02-04 13:55:04 · 1573 阅读 · 0 评论 -
topcoder srm606 div2
250pt:题目:Problem Statement Elly has a string S of uppercase letters and a magic device that can modify the string. The strength of the device is an intL.The device does原创 2014-01-30 20:42:19 · 2042 阅读 · 0 评论 -
hdu 1042 阶乘--大数乘法
这里练习一下大数乘法的写法,具体就是使用模拟,如100!*101的时候,将前者的每一位都乘以101,然后再处理每一位的进位问题,每一位都存在一个int的大数组里面,代码非常简单,如下:#include#include#includeusing namespace std;int result[40000];int main(){ int n; while(cin>>n) {原创 2013-05-27 22:06:56 · 1426 阅读 · 0 评论 -
hdu 1059 练习练习dp(多重背包)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1059经典的多重背包问题,有若干个数,每个数可以取若干个,求问能不能取到总和的一半直接把模板一敲就差不多了~#include#include#include#includeusing namespace std;const int size = 600000;int su原创 2013-07-04 13:52:16 · 1165 阅读 · 1 评论 -
初学数位DP--hdu 2089
其实是做topcoder的时候碰到不会的题,看人家说要用数位dp,所以拿http://acm.hdu.edu.cn/showproblem.php?pid=2089来学习了一下数位dp适合在一段数的区间内找出满足某些条件的数的个数,这个时候往往不能之间遍历,肯定会超时,则一般使用数位dp来解决数位dp的常见形式是dp[i][j],表示开头是j的i位数满足条件的有多少个,当然也有其他dp[i原创 2013-10-30 23:59:04 · 8058 阅读 · 6 评论 -
STL中hashtable,hashset,hashmap,set,map,multiset和multimap的区别
hashtable 可以提供任何有名项的存取操作和删除操作,由于操作对象是有名项,故可被视为一种字典结构。用意是在常数时间内提供基本操作。常见的,我们可以把int存到相应值的数组里面,就可以通过O(1)的时间存取和删除。主要思想是通过hash函数,把对象映射到一个较小的容器里面,并且保证时间复杂度。映射到较小容器很可能出现碰撞问题,解决的方法常见的有:线性探测,二次探测,开链法。STL利用vect原创 2013-10-30 21:34:45 · 8713 阅读 · 0 评论 -
topcoder SRM598 div1
250pt:题意:提供每一件物品的重量item[i], 100分析:贪心。除了三个都是100的能放在一个容器里,其他的最多两个。这样对100的个数(更确切的说是有多少组3个100)进行枚举讨论。注意,并不是有3个100就一定这三个放在一个容器里,比如100,100,100,180,180,180,更好的方案是100+180一组,所以要讨论3个100是否放一个容器的情况。 剩下的就是先排序,原创 2013-11-29 15:46:17 · 1064 阅读 · 0 评论 -
Codeforces Round #216 (Div. 2)
500pt:题目连接:http://codeforces.com/problemset/problem/369/A思路:直接贪心,注意一次只能洗一只碗,一开始以为洗一次能把所有都洗好。。。代码:#include #include #include #include #include #include #include #include #include #incl原创 2013-11-30 13:44:16 · 989 阅读 · 0 评论 -
codeforce goodbye 2013
500pt:链接:http://codeforces.com/contest/379/problem/A分析:每b根就能再生成一根,本着不要浪费的原则就行代码:#include #include #include #include #include #include #include #include #include #include #include #i原创 2013-12-31 11:00:16 · 1009 阅读 · 0 评论 -
Codeforces Round #221 (Div. 2)
500pt:链接:http://codeforces.com/problemset/problem/376/A分析:水题,模拟实现一下就行,要注意的是支点左右的和要用long long 来做,不然会错代码:#include #include #include #include #include #include #include #include #include原创 2013-12-25 14:47:28 · 1099 阅读 · 0 评论 -
codeforce round#226 div2
500pt:链接:http://codeforces.com/problemset/problem/385/A分析:找前一个减后一个差最大的就行代码:#include #include #include #include #include #include #include #include #include #include #include #includ原创 2014-01-25 12:50:07 · 1336 阅读 · 0 评论 -
Codeforces Round #296 (Div. 2)
A题:http://codeforces.com/contest/527/problem/A A. Playing with Papertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutp原创 2015-03-23 17:44:04 · 1540 阅读 · 0 评论