自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(78)
  • 收藏
  • 关注

转载 c++ 类的构造顺序

在单继承的情况下,父类构造先于子类,子类析构先于父类,例:class A {public: A() { cout << "A" << endl; } ~A() { cout << "~A" << endl; }};class B : publ...

2015-03-21 21:30:00 371

转载 static, const 和 static const 变量的初始化问题

const 常量的在超出其作用域的时候会被释放,但是 static 静态变量在其作用域之外并没有释放,只是不能访问。static 修饰的是静态变量,静态函数。对于类来说,静态成员和静态函数是属于整个类的,而不是属于对象。可以通过类名来访问,但是其作用域限制于包含它的文件中。static 变量在类内部声明,但是必须在类的外部进行定义和初始化。const 常量在类内部声明,但是定...

2015-03-20 21:11:00 497

转载 clog,cout,cerr 输出机制

clog:控制输出,使其输出到一个缓冲区,这个缓冲区关联着定义在 <cstdio> 的 stderr。cerr:强制输出刷新,没有缓冲区。cout:控制输出,使其输出到一个缓冲区,这个缓冲区关联着定义在 <ostream> 的 stdout。但是我们分别测试如下三个程序的结果如下:cout:#include <iostream>...

2015-03-19 10:53:00 902

转载 sicily 1215. 脱离地牢

Description在一个神秘的国度里,年轻的王子Paris与美丽的公主Helen在一起过着幸福的生活。他们都随身带有一块带磁性的阴阳魔法石,身居地狱的魔王Satan早就想得到这两块石头了,只要把它们熔化,Satan就能吸收其精华大增自己的魔力。于是有一天他趁二人不留意,把他们带到了自己的地牢,分别困在了不同的地方。然后Satan念起了咒语,准备炼狱,界时二人都将葬身于这地牢里...

2014-12-15 16:21:00 226

转载 UVA 11729 Commando War

Commando WarInput: Standard InputOutput: Standard Output “Waiting for orders we held in the wood, word from the front never cameBy evening the sound of the gunfire was miles awayAh softly we mov...

2014-12-08 21:00:00 91

转载 sicily 1231. The Embarrassed Cryptography

Time Limit: 2sec Memory Limit:32MBDescriptionThe young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of u...

2014-11-30 12:24:00 111

转载 sicily 1500. Prime Gap

DescriptionThe sequence of n ? 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numberspandp+nis called a p...

2014-11-30 11:17:00 101

转载 sicily 1388. Quicksum

DescriptionA checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often...

2014-11-30 10:43:00 76

转载 sicily 1119. Factstone Benchmark

DescriptionAmtel has announced that it will release a 128-bit computer chip by 2010, a 256-bit computer by 2020, and so on, continuing its strategy of doubling the word-size every ten years. (A...

2014-11-30 10:13:00 121

转载 sicily 1459. The Dragon of Loowater

Time Limit: 1sec Memory Limit:32MBDescriptionOnce upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.The shores of Rellau ...

2014-11-18 10:41:00 113

转载 sicily 1240. Faulty Odometer

DescriptionYou are given a car odometer which displays the miles traveled as an integer. The odometer has a defect, however: it proceeds from the digit 3 to the digit 5, always skipping over th...

2014-11-17 21:58:00 122

转载 sicily 1259. Sum of Consecutive Primes

DescriptionSome positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example...

2014-11-17 21:38:00 149

转载 如何用enable_shared_from_this 来得到指向自身的shared_ptr 及对enable_shared_from_this 的理解...

在看《Linux多线程服务端编程:使用muduo C++网络库》 的时候,在说到如何防止在将对象的 this 指针作为返回值返回给了调用者时可能会造成的 core dump。需使用enable_share_from_this。  首先要说明的一个问题是如何安全地将 this 指针返回给调用者。一般来说,我们不能直接将 this 指针返回。想象这样的情况,该函数将 this 指针返回...

2014-11-15 18:09:00 142

转载 mac 上使用octave的plot错误的解决办法

在mac10.10上使用octave的时候,键入 plot(x, y)的时候会出现如下错误:set terminal aqua enhanced title "Figure 1" font "*,6" dashlength 1 ^   line 0: unknown or ambiguous terminal type; type just 'set terminal' ...

2014-11-09 18:37:00 285

转载 sicily 1003. Hit or Miss

DescriptionOne very simple type of solitaire game known as "Hit or Miss" (also known as "Frustration," "Harvest," "Roll-Call," "Talkative", and "Treize") is played as follows: take a standard...

2014-11-09 11:29:00 100

转载 动态规划 -- 钢条切割

/* 动态规划和分治法相似,都是通过组合子问题的解来求解原问题。 但分治法是将问题划分为互不相交的子问题,递归地求解子问题,再将它们的解组合起来,求出原问题的解。与之相反,动态规划应用于子问题重叠的情况,即不同的子问题具有公共的子问题。在这种情况下,分治法会做很多不必要的工作。 动态规划方法通常用来求解最优化问题,这类问题通常有很多可行解。我们希望寻找...

2014-11-03 01:08:00 103

转载 求解最大子数组问题 -- 暴力求解 和 分治法求解

/*------------------ 求解最大子数组问题 --------------- 最大子数组,就是求解一个数组的所有元素的各种组合中,和最大的那个子数组。在这种情况下,如果元素值全部非负,那么最大子数组当然是所有元素。但是如果有负值的元素存在,那么久需要找到一个由数组中连续几个元素组成的子数组并且其元素值之和最大。*/#include &...

2014-11-02 19:55:00 413

转载 sicily 1193. Up the Stairs

Time Limit: 1sec Memory Limit:32MBDescriptionJohn is moving to the penthouse of a tall sky-scraper. He packed all his stuff in boxes and drove them to the entrance of the b...

2014-11-01 20:13:00 111

转载 sicily 1017. Rate of Return

DescriptionJill has been investing in a mutual fund for a while. Since her income has varied, the amount of money she has added to the investment has varied, and she hasn’t always added to th...

2014-11-01 18:11:00 152

转载 sicily 1034. Forest

DescriptionIn the field of computer science, forest is important and deeply researched , it is a model for many data structures . Now it’s your job here to calculate the depth and width of gi...

2014-10-26 14:38:00 105

转载 sicily 1172. Queens, Knights and Pawns

DescriptionYou all are familiar with the famous 8-queens problem which asks you to place 8 queens on a chess board so no two attack each other. In this problem, you will be given locations of...

2014-10-26 13:13:00 141

转载 sicily 1029. Rabbit

DescriptionThe rabbits have powerful reproduction ability. One pair of adult rabbits can give birth to one pair of kid rabbits every month. And after m months, the kid rabbits can become adul...

2014-10-18 17:32:00 153

转载 sicily 1211. 商人的宣传

DescriptionBruce是K国的商人,他在A州成立了自己的公司,这次他的公司生产出了一批性能很好的产品,准备宣传活动开始后的第L天到达B州进行新品拍卖,期间Bruce打算将产品拿到各个州去做推销宣传,以增加其影响力。K国有很多个州,每个州都与其他一些州相邻,但是K国对商人作宣传却有一些很奇怪的规定:1、商人只能从某些州到达另外一些州,即连通路线是单向的,而且有些州...

2014-10-18 13:37:00 84

转载 sicily 1052. Candy Sharing Game

ConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionA number of students sit in a circle facing their teacher in the center. Each student initially has an even number of pieces of...

2014-10-14 21:38:00 118

转载 sicily 1012. Stacking Cylinders & 1206. Stacking Cylinders

Time Limit: 1sec Memory Limit:32MBDescriptionCylinders (e.g. oil drums) (of radius 1 foot) are stacked in a rectangular bin. Each cylinder on an upper row rests on two cy...

2014-10-14 14:42:00 102

转载 sicily 1059. Exocenter of a Trian

DescriptionGiven a triangle ABC, the Extriangles of ABC are constructed as follows:On each side of ABC, construct a square (ABDE, BCHJ and ACFG in the figure below).Connect adjacent square ...

2014-10-13 12:36:00 106

转载 sicily 1153. 马的周游问题

一、题目描述在一个8 * 8的棋盘中的某个位置有一只马,如果它走29步正好经过除起点外的其他位置各一次,这样一种走法则称马的周游路线,试设计一个算法,从给定的起点出发,找出它的一条周游路线。为了便于表示一个棋盘,我们按照从上到下,从左到右对棋盘的方格编号,如下所示:1 2 3 4 5 6 7 89 1...

2014-10-12 14:53:00 195

转载 1438. Shopaholic

ConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionLindsay is a shopaholic. Whenever there is a discount of the kind where you can buy three items and only pay for two, she goes ...

2014-10-11 20:26:00 132

转载 1028. Hanoi Tower Sequence

DescriptionHanoi Tower is a famous game invented by the French mathematician Edourard Lucas in 1883. We are given a tower of n disks, initially stacked in decreasing size on one of three pegs...

2014-10-11 20:24:00 128

转载 sicily 1063. Who's the Boss

Time Limit: 1sec Memory Limit:32MBDescriptionSeveral surveys indicate that the taller you are, the higher you can climb the corporate ladder. At TALL Enterprises Inc. this ...

2014-10-06 20:45:00 98

转载 sicily 1009. Mersenne Composite N

DescriptionOne of the world-wide cooperative computing tasks is the "Grand Internet Mersenne Prime Search" -- GIMPS -- striving to find ever-larger prime numbers by examining a particular categ...

2014-10-05 19:07:00 132

转载 1006. Team Rankings

DescriptionIt's preseason and the local newspaper wants to publish a preseason ranking of the teams in the local amateur basketball league. The teams are the Ants, the Buckets, the Cats, the Dr...

2014-10-05 17:13:00 72

转载 sicily 1036. Crypto Columns

ConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionThe columnar encryption scheme scrambles the letters in a message (or plaintext) using a keyword as illustrated in the followin...

2014-10-05 16:01:00 83

转载 sicily 1001. Fibonacci 2

                              1001. Fibonacci 2DescriptionIn the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn-1 + Fn-2 for n ≥ 2. For example, the first ten terms of the Fibon...

2014-09-27 20:50:00 65

转载 sicily 1051. Biker's Trip Odomete

                                1051. Biker's Trip OdometeTime Limit: 1sec Memory Limit:32MBDescriptionMost bicycle speedometers work by using a Hall Effect sensor fastened ...

2014-09-27 17:48:00 109

转载 sicily 1046. Plane Spotting

                                1046. Plane SpottingTime Limit: 1sec Memory Limit:32MBDescriptionCraig is fond of planes. Making photographs of planes forms a major part o...

2014-09-27 17:32:00 58

转载 sicily 1035. DNA matching

DescriptionDNA (Deoxyribonucleic acid) is founded in every living creature as the storage medium for genetic information. It is comprised of subunits called nucleotides that are strung togeth...

2014-09-27 15:22:00 41

转载 一个函数返回临时对象引起的编译器优化问题

我们都知道,如果在一个函数调用另一个函数,假设是 main 函数调用 fun 函数,这个 fun 函数返回一个临时类类型变量,那么这个时候编译器就会在 main 函数申请一个空间并生成一个临时对象,通过拷贝构造函数将 fun 返回的临时变量的值拷贝到这个临时对象。我们看如下的代码:#include <iostream> #include <cstring&g...

2014-09-24 21:38:00 262

转载 sicily 1020. Big Integer

DescriptionLong long ago, there was a super computer that could deal with VeryLongIntegers(no VeryLongInteger will be negative). Do you know how this computer stores the VeryLongIntegers? Thi...

2014-09-23 20:56:00 73

转载 关于c++的string的operator =

在 c++ primer 5 中在说到string的章节里面有这样一句话:string s5 = "hiya"; // copy initialization也就是说,这里说上面这句是拷贝初始化,也就是调用拷贝构造函数。而下面这句:string s6("hiya"); // direct initialization却又是...

2014-09-20 18:55:00 819

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除