自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

靖空间

降低成功的时间复杂度,提高生活的空间复杂度

  • 博客(88)
  • 资源 (5)
  • 收藏
  • 关注

原创 codeforces A. Valera and Plates 题解

本题也是使用暴力法了。最难的就是读懂题目了。原来这个家伙这么赖,一次只洗一个碗,从不肯多洗。有两个思路:1 计算多少碟菜,多少个碗和碟,然后进行加减处理2 模拟他洗碗的过程两种方法都需要O(n)时间效率。方法1:

2014-04-30 20:37:02 1294

原创 codeforces A. Cakeminator 题解

本题思路:1 先扫描行,如果可以吃,就数吃了多少格,然后做好标志2 在扫描列,同样处理扫描完就可以出答案了。时间效率是O(n*m)了。算是暴力法

2014-04-30 19:23:26 1255

原创 Codeforce Circle Line 环形数据操作

The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations:d1 is the distance between the 1-st and the 2-nd station;d2 is the d

2014-04-30 16:19:05 1172

原创 codeforce Present from Lena 打印菱形

Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit 

2014-04-30 14:55:54 1701

原创 codeforces Buttons 数学公式构建

这样的题目虽然不难,但是要构建个数学公式还真不容易的。做多了,居然有感觉了,可以感知到大概公式是什么样的,然后验证它。本题公式就是:S = n + (n-1) + (n-2) * 2 + (n - 3) * 3 ...至于怎么想出来的?

2014-04-30 13:46:50 1307

原创 CodeForces Dubstep 题解

抽掉中间的WUB字符串。这个是用C++总是有点难度的。本题还算简单的了,只要注意中间插入空格符就好了。这里虽然是用了二次循环,但是实际时间效率是O(n)

2014-04-30 13:26:07 1813

原创 Codeforces Amusing Joke 题解

So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letter

2014-04-30 12:23:49 1632

原创 codeforces Arrival of the General 题解

相当于一个简单的冒泡排序了,不过不用直接排序,只是计算一下而已。注意1 最大值和最小值交换的时候可以减少一次交换的。2 元素是会重复的。

2014-04-30 09:22:55 1183

原创 codeforces Epic Game 题解

这样的题目一般都可以找公式的,但是本题却是找不到什么好的公式了。只有暴力去模拟玩这个游戏了。还好因为其数据不大,故此也许出题者也是没有公式的。

2014-04-30 07:16:10 1697

原创 Codeforces Helpful Maths

Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.The teacher has written down the sum of multiple numbers. Pupils should ca

2014-04-30 07:11:35 1315

原创 Codeforces A. Double Cola 题解

题目很奇怪,就是5个人排队喝可乐,喝完之后编程两个人,然后拍在队后面,然后继续喝可乐。给出个数值,代表第几罐可乐,问会是第几个人喝到?http://codeforces.com/problemset/problem/82/A一个数学问题,仔细点就好了。要熟练的知识点:1 要熟悉解决这种递增数列,如何减去循环部分2 要知道如何计算,求余取答案

2014-04-29 18:16:08 1459

原创 Timus 1119. Metro 动态规划

很好的一道动态规划法题目。注意:1 行列别搞错了,要很细心一点一点对起来2 要以边线思考,不要以方块来计算, N*M个方块就成了(N+1)*(M+1)条交叉线了,最下面和最左边的线就方便初始化了3 注意C++的四舍五入的方法动态规划的状态转移方程:if (A[y][x]) B[x] = t + 1.414213562;else B[x] = min(B[x-1], B[x]) + 1 ;A[y][x]表示是否有对角线,有对角线必定是走对角线的。

2014-04-29 15:05:12 1509

原创 Timus 1104. Don’t Ask Woman about Her Age题解

Mrs Little likes digits most of all. Every year she tries to make the best number of the year. She tries to become more and more intelligent and every year studies a new digit. And the number she make

2014-04-29 12:27:07 2517

原创 Timus 1446. Sorting Hat 分类问题

At the start of each school year, a very important event happens at Hogwarts. Each of the first-year wizards and witches is assigned to one of the four Hogwarts houses. The bravest children are put

2014-04-29 09:31:03 1369

原创 Timus 1777. Anindilyakwa 奇怪的数数问题

本题可以使用长整形来记录数据的,因为最长不过10^8,但是如果把这题当做是无穷大数来做的话,难度指数就直线上升了。这里给出使用string来做无穷大减法的解法。要处理的问题:1 string大小比较问题,不能使用原始的<号2 如何进位的问题3 符号问题,因为这里只求差异就可以了,所以返回绝对值就够了。这样做本题还是有一定难度, 而且可以锻炼到一些高级点的知识的运用,挺好。

2014-04-29 08:43:12 1088

原创 Timus 1644. A Whole Lot of Walnuts 算法

Ten big walnuts is a whole lot of walnuts, that's for sure! Two walnuts is too little for anybody. How about six walnuts? Is it a small number of walnuts or a large one? The Parrot has already found

2014-04-28 19:26:17 741

原创 Timus 1510. Order 找到出现次数过半的数

又是一个新的算法,原来可以这样查找的。我的一句话理解的思想:计算可以抵消的数量,那么如果一个数出现的次数超过半那么最终这个数肯定不会被抵消完。这个思想叫 Moore’s Voting Algorithm有了这个思想武器之后,程序就可以写的很简单,可以很清楚看到怎么实现的,参考资料可以看:

2014-04-28 18:19:33 1393

原创 Timus 1161. Stripies

Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent an English name to app

2014-04-28 16:08:17 1049

原创 Timus 1642. 1D Maze迷宫

1D people lived in a 1D country. Everything in the country was one-dimensional, and everything was simple and clear: just one axis and two directions — forward and backward. Even a 1D world has proble

2014-04-28 15:28:36 1039

原创 Timus 2002. Test Task 一个登陆系统

实现一个登陆系统。思路:1 使用map,在map中的就是已经注册的了2 使用数据结构保存用户名,是否登陆和密码3 使用if else判断处理第一个字符串-命令类似很多人都写的什么图书馆管理系统,什么信息系统之类的登陆控制管理,都是很简单的东西,一步一步写就不会错了,完成速度相当于打字速度。

2014-04-28 15:04:21 1168

原创 Timus 1601. AntiCAPS 修正大写句子

The blonde Angela has a new whim: internet chats. Of course, as any blonde, she writes her messages using the upper case. You are the moderator of Angela's favorite chat and you're fed up with her upp

2014-04-28 14:59:10 1470

原创 Timus 1180. Stone Game 游戏题目

这也是个有趣的问题,也很经典的游戏题目的变形了。不过这道题扩展了成为无限大的数了。类似的游戏有:没人可以拿掉桌面上的棋子,每次不能超过5个,最后没棋子可以拿的算输解决这样的题目只能是寻找规律了,不能真的模拟区玩了,否则必定超时。这道题目的规律就是:1 如果给出的stone是3的倍数,那么先取者必输2 如果给出的不是3的倍数,那么先取者就凑成3的倍数就必赢,因为凑3的倍数很容易,去掉1个或者2个必定可以凑出来了所以最后问题就成了mod3问题了。我是怎么想出来的?我是一个列子一个例子去观察,

2014-04-28 09:02:00 1175

原创 Timus 1796. Amusement Park 聪明题

这是一道考人是否聪明的题目,没有现成的算法。所以需要模拟人计算的过程,用计算机的程序思维去思考。过程这样的:1 先算出总钱数能购买多少张票2 总钱数减去一张最小面值的钱,然后模票价,然后加上最小面值的钱,在减去一张票价,最后就得到灵活度的钱3 灵活度的钱除以票价,就得到灵活度了,灵活度的钱除以票价得到零,那么就只有一种可能了,得到1就有两种可能难以理解的话,就细心想想人是如何计算的就可以解决了。

2014-04-28 07:52:16 1200

原创 Timus 2011. Long Statement 排列组合的运用

本题我使用了permutation的知识去解决。就是把 1 2 2 3 3 3 看着是一个排列,然后求6次下一个排列,如果无重复,那么就是Yes,如果有重复,那么就是No了。求排序的时间效率是O(n),所以本算法的速度还是相当快的。能够运用上学过的知识,感觉真是太好了。

2014-04-27 20:44:23 1183

原创 Timus 1404. Easy to Hack! 有一个密码问题

When Vito Maretti writes an important letter he encrypts it. His method is not very reliable but it’s enough to make any detective understand nothing in that letter. Sheriff doesn’t like such state

2014-04-27 20:04:54 877

原创 Timus 1120. Sum of Sequential Numbers 数学题

There is no involute formulation concerning factitiously activity of SKB Kontur in this problem. Moreover, there is no formulation at all.InputThere is the only number N, 1 ≤ N ≤ 109.O

2014-04-27 19:31:41 1102

原创 Timus 1139. City Blocks 题解

The blocks in the city of Fishburg are of square form. N avenues running south to north and Mstreets running east to west bound them. A helicopter took off in the most southwestern crossroads and fl

2014-04-27 16:50:29 1259

原创 Timus 2005. Taxi for Programmers 题解

摆明的一个TSP问题,但是解决TSP问题的效率是相当低的。不过这里的点数很少,而且有一个条件限制。所以最后剩下的可选择的路径就很少了。于是这里我使用了暴力法,可以很轻松地通过。技巧就是:预先产生了路径,那么速度就快了。

2014-04-27 10:53:22 958

原创 Timus 1712. Cipher Grille 题解

很有意思的一个加密题目。加密方法:就是弄一个加密版,然后弄个纸 方块,这个纸方块中间开了特定的4个空,先贴在加密版上,写下4个字母,然后顺时针选择90度,再写下4个字母,继续选择2次,写下16个字母,就是最后的密码了。现在写个解密算法。考的知识点就是:旋转数组的问题。

2014-04-27 09:15:53 1255

原创 Timus 1935. Tears of Drowned 详解

这是个十分难理解的题目,一难:难理解题意; 二难:难理解算法题意简略为:把一些奇怪的湿蝙蝠皮夹在书中,每张蝙蝠皮都带一个值,每张蝙蝠皮的两边的书的页数不能少于这个值,求最小需要使用多少页书的书本?很奇怪吧,不过她是说个魔法故事的,多奇怪都不奇怪,O(∩_∩)O~本题算法:例子中为什么是28呢?误解:5页+max(5,10) + max(10, 3) + 3 = 28正解:3页+max(3, 5)+max(5, 10)+10 = 28再看一个例子:61 3 2 5 4 6误解:1页+ma

2014-04-27 07:28:46 1219

原创 Timus 1025. Democracy in Danger 题解

有两个思路:1 先排序,然后从最小的值中取半数+1的值,就得到解了2 使用priority_queue,就可以不排序,直接大数出列,小数入列,也可以很容易解决。两个思路的时间效率都是O(n),但是运行起来应该是第二个思路比较快点。这里使用priority_queue来解题。

2014-04-26 19:34:52 1304

原创 Timus 1654. Cipher Message 破解密码

这道题目其实十分有趣的。如果按照原文叙述求思考,那么就很可能犯错的。我们应该换一个角度来思考。题目的意思就变成:如果字符重复出现的次数是双次,那么就删除这个字符,如果出现的次数是单次,那么就保留这个字符。这样诠释之后,题目豁然开朗,原来就是一个简单的操作字符串的问题。这样写不会有bug。网上有些博客写这道题目的程序是有bug的,应付不了所有特殊情况,不过这道题的测试用例似乎不是那么强,没有全面地测试所有特殊情况。

2014-04-26 18:44:48 1485

原创 Timus 1792. Hamming Code 题解

Let us consider four disks intersecting as in the figure. Each of the three shapes formed by the intersection of three disks will be called a petal.Write zero or one on each of the disks. Then w

2014-04-26 15:34:56 1313

原创 Timus 1131. Copying 数学公式的构造

这种题目一般都无法模拟它的工作过程的了,否则铁定超时了。所以这样的题目必定是利用数学知识构造公式。注意观察:1 有充裕的k可以使用的时候,每个小时可以拷贝的电脑都是呈倍数增长的,得到数列:1 2 4 8 16 32...2 当k不够用的时候就是每个小时增加k台电脑:k 2k 3k 4k...这样就可以构造公式了,看程序如何实现:最终的时间效率是O(lgn)

2014-04-26 14:25:26 1060

原创 Timus 1837. Isenbaev's Number 图论 题解

本题属于图论的应用了。有两个思路:1 Dijstra求一点都其他所有点的最短路径2 宽度优先的图搜索两者的时间效率和空间效率都是一样的。难度指数看情况而定吧。有人说很简单。但是对于对图论不太熟悉的人来说就一点都不简单了。尤其是使用C++来实现更加难,因为要操作繁琐的指针问题。本人对图论也不够熟,所以本题对我来说还是挺有难度的。做熟了LeetCode题目,但是LeetCode题好像只有一题是牵涉图论的,还是复制图问题,相当于遍历问题了。我这里使用第二个思路来做:1 读入数据,同时构造

2014-04-26 13:19:06 1887

原创 Timus 1723. Sandro's Book 题解

It's been quite a number of years since Lich Sandro retired. Sometimes in the evenings, when he feels especially lonely, he takes a book that was presented to him by his student magicians on the occas

2014-04-25 18:41:15 1291

原创 Timus 1149. Sinus Dances 打印复杂公式

就是打印下面这两个复杂的式子:Let An = sin(1–sin(2+sin(3–sin(4+…sin(n))…)Let Sn = (…(A1+n)A2+n–1)A3+…+2)An+1For given N print SNInputOne integer N. 1 ≤ N ≤ 200OutputLine containing SN

2014-04-25 15:35:00 1205

原创 Timus 1545. Hieroglyphs Trie的即学即用 实现字典提示功能

前面学了Trie,那么就即学即用,运用Trie数据结构来解决这道题目。本题目比较简单,当然可以不使用Trie,不过多用高级数据结构还是很有好处的。

2014-04-25 12:44:47 1081

原创 GeekforGeeks Trie - 键树简介 - 构造 插入 和 搜索

Trie是非常高效的信息检索数据结构, 时间效率会是O(m),其中m是需要搜索的关键字的长度。缺点就是需要的存储空间大。Trie的特点:1. 每个Trie的节点都由多个分支构成2. 每个分支代表可能的关键字的一个字符3. 需要mark(标志)每个关键字的最后一个字符为leaf node(叶子节点)英文字母的节点数据结构可以表示如下:struct TrieNode{ in

2014-04-25 10:37:54 1474 2

原创 Timus - 1110. Power 除尽问题

You are given the whole numbers N, M and Y. Write a program that will find all whole numbers X in the interval [0, M − 1] such that XN mod M = Y.InputThe input contains a single line with N,

2014-04-24 19:58:22 1036

OpenGL完美的心形

可以参考本人博客: http://blog.csdn.net/kenden23/article/details/27338943 是一个使用OpenGL FreeGlut画的一个完美的心形。

2014-05-28

简单Windows弹球程序

详细描述,请看下面博客: http://blog.csdn.net/kenden23/article/details/17268877

2013-12-14

第一人称3D镜头框架代码

http://blog.csdn.net/kenden23/article/details/14051187 这个博客讲解的代码框架。讲解的类部分另外下载,可在博客上找。

2013-11-02

第一人称3D镜头类

http://blog.csdn.net/kenden23/article/details/14051187 这个博客讲解的代码,可以实现一个3d漫游第一人称视觉的类。一个镜头类,可以控制3D视觉,实现漫游效果

2013-11-02

算法问题集合源文件 堆排序 吊桶排序 最大子段和等

这个是本博客算法专栏的部分.cpp源文件,方便大家打包下载,如果没有积分的话,可以到我博客粘贴,博客有完整的代码。 http://blog.csdn.net/column/details/billsalgorithm.html?page=1#12944927 这里是部分源文件,暂时没时间全部做好。 可以直接加入项目运行的,建议使用vs2012编译。

2013-10-22

空空如也

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

TA关注的人

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