自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

codeforces Epic Game 题解

Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives numberaand Antisimon receives numberb. They a...

2014-04-30 07:16:00 1067

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. ...

2014-04-30 07:11:00 926

Unique Binary Search Trees -- LeetCode

原题链接:http://oj.leetcode.com/problems/unique-binary-search-trees/这道题要求可行的二叉查找树的数量,其实二叉查找树可以任意取根,只要满足中序遍历有序的要求就可以。从处理子问题的角度来看,选取一个结点为根,就把结点切成左右子树,以这个结点为根的可行二叉树数量就是左右子树可行二叉树数量的乘积,所以总的数量是将以所有结点为根的可行结果累加起来...

2014-04-30 06:16:00 989

Unique Binary Search Trees II -- LeetCode

原题链接:http://oj.leetcode.com/problems/unique-binary-search-trees-ii/这道题是求解所有可行的二叉查找树,从Unique Binary Search Trees中我们已经知道,可行的二叉查找树的数量是相应的卡特兰数,不是一个多项式时间的数量级,所以我们要求解所有的树,自然是不能多项式时间内完成的了。算法上还是用求解NP问题的方法来求...

2014-04-30 06:15:00 315

【图像处理】Gabor滤波器

Gabor的核函数参考的wiki使用实数Real的公式计算核函数代码:Mat gaborFilter(Mat& img, Mat& filter){ int half_filter_size = (max(filter.rows,filter.cols)-1)/2; Mat filtered_img(img.rows,img.cols,CV_32F); for(int...

2014-04-30 00:36:00 394

Codeforces A. Double Cola 题解

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

2014-04-29 18:16:00 327

Timus 1119. Metro 动态规划

Many of SKB Kontur programmers like to get to work by Metro because the main office is situated quite close the station Uralmash. So, since a sedentary life requires active exercises off-duty, man...

2014-04-29 15:05:00 209

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 ...

2014-04-29 12:27:00 257

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 pu...

2014-04-29 09:31:00 213

Timus 1777. Anindilyakwa 奇怪的数数问题

The language of Australian aborigines anindilyakwa has no numerals. No anindilyakwa can say: “I've hooked eight fishes”. Instead, he says: “I've hooked as many fishes as many stones are in thi...

2014-04-29 08:43:00 192

Restore IP Addresses -- LeetCode

原题链接:http://oj.leetcode.com/problems/restore-ip-addresses/这道题的解法非常接近于NP问题,也是采用递归的解法。基本思路就是取出一个合法的数字,作为IP地址的一项,然后递归处理剩下的项。可以想象出一颗树,每个结点有三个可能的分支(因为范围是0-255,所以可以由一位两位或者三位组成)。并且这里树的层数不会超过四层,因为IP地址由四段组成,到了...

2014-04-29 05:01:00 174

Interleaving String -- LeetCode

原题链接:http://oj.leetcode.com/problems/interleaving-string/这是一道关于字符串操作的题目,要求是判断一个字符串能不能由两个字符串按照他们自己的顺序,每次挑取两个串中的一个字符来构造出来。像这种判断能否按照某种规则来完成求是否或者某个量的题目,很容易会想到用动态规划来实现。先说说维护量,res[i][j]表示用s1的前i个字符和s2的前j个字符能...

2014-04-29 04:28:00 221

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 fou...

2014-04-28 19:26:00 171

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

A New Russian Kolyan likes two things: money and order. Kolyan has lots of money, but there is no order in it. One beautiful morning Kolyan understood that he couldn't stand this any longer and de...

2014-04-28 18:19:00 241

Timus 1161. Stripies

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

2014-04-28 16:08:00 187

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 pr...

2014-04-28 15:28:00 216

Timus 2002. Test Task 一个登陆系统

It was an ordinary grim October morning. The sky was covered by heavy gray clouds. It was a little rainy. The rain drops fell on the windows with quiet bangs. Ilya was sitting at the computer and ...

2014-04-28 15:04:00 169

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...

2014-04-28 14:59:00 217

Timus 1180. Stone Game 游戏题目

Two Nikifors play a funny game. There is a heap ofNstones in front of them. Both Nikifors in turns take some stones from the heap. One may take any number of stones with the only condition that ...

2014-04-28 09:02:00 186

Timus 1796. Amusement Park 聪明题

On a sunny Sunday, a group of children headed by their teacher came to an amusement park. Aunt Frosya, who was a very kind and quiet person, worked at the ticket window on that day. The teacher ga...

2014-04-28 07:52:00 206

Reverse Linked List II -- LeetCode

原题链接:http://oj.leetcode.com/problems/reverse-linked-list-ii/这道题是比较常见的链表反转操作,不过不是反转整个链表,而是从m到n的一部分。分为两个步骤,第一步是找到m结点所在位置,第二步就是进行反转直到n结点。反转的方法就是每读到一个结点,把它插入到m结点前面位置,然后m结点接到读到结点的下一个。总共只需要一次扫描,所以时间是O(n),只需...

2014-04-28 04:58:00 159

Subsets II -- LeetCode

原题链接:http://oj.leetcode.com/problems/subsets-ii/这道题跟Subsets一样是经典的NP问题--求子集。比Subsets稍微复杂一些的是这里的集合中可能出现重复元素,因此我们在求子集的时候要避免出现重复的子集。在Subsets中我们每次加进一个元素就会把原来的子集都加上这个元素,然后再加入到结果集中,但是这样重复的元素就会产生重复的子集。为了避免这...

2014-04-28 04:23:00 152

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

Nikita, a schoolboy, is currently taking part in one of programming contests. He is really upset because all the problem statements are so long and unclear. So he took the statement of the first p...

2014-04-27 20:44:00 114

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 stat...

2014-04-27 20:04:00 143

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 numberN, 1 ≤N≤ 109....

2014-04-27 19:31:00 143

Timus 1139. City Blocks 题解

The blocks in the city of Fishburg are of square form.Navenues running south to north andMstreets running east to west bound them. A helicopter took off in the most southwestern crossroads and f...

2014-04-27 16:50:00 156

Timus 2005. Taxi for Programmers 题解

The clock shows 11:30 PM. The sports programmers of the institute of maths and computer science have just finished their training. The exhausted students gloomily leave their computers. But there’...

2014-04-27 10:53:00 146

Timus 1712. Cipher Grille 题解

Our program committee uses different tools for problem development: a mailing list, a version control system, an administration system of theTimus Online Judgewebsite, and many others. Chairman ...

2014-04-27 09:15:00 173

Timus 1935. Tears of Drowned 详解

Old Captain Jack Sparrow’s friend Tia Dalma, the fortuneteller and prophetess, often makes potions. She has an outstanding collection of the rarest ingredients such as rat tails, fingers of drowne...

2014-04-27 07:28:00 153

Decode Ways -- LeetCode

原题链接:http://oj.leetcode.com/problems/decode-ways/这道题要求解一个数字串按照字符串编码方式可解析方式的数量。看到这种求数量的,我们很容易想到动态规划来存储前面信息,然后迭代得到最后结果。我们维护的量res[i]是表示前i个数字有多少种解析的方式,接下来来想想递归式,有两种方式:第一种新加进来的数字不然就是自己比较表示一个字符,那么解析的方式有res[...

2014-04-27 06:18:00 169

Recover Binary Search Tree -- LeetCode

原题链接:http://oj.leetcode.com/problems/recover-binary-search-tree/这道题是要求恢复一颗有两个元素调换错了的二叉查找树。一开始拿到可能会觉得比较复杂,其实观察出规律了就比较简单。主要还是利用二叉查找树的主要性质,就是中序遍历是有序的性质。那么如果其中有元素被调换了,意味着中序遍历中必然出现违背有序的情况。那么会出现几次呢?有两种情况,如果...

2014-04-27 03:09:00 161

Timus 1025. Democracy in Danger 题解

BackgroundIn one of the countries of Caribbean basin all decisions were accepted by the simple majority of votes at the general meeting of citizens (fortunately, there were no lots of them). O...

2014-04-26 19:34:00 198

Timus 1654. Cipher Message 破解密码

Müller tried to catch Stierlitz red-handed many times, but always failed because Stierlitz could ever find some excuse. Once Stierlitz was looking through his email messages. At that moment, Mülle...

2014-04-26 18:44:00 138

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 apetal.Write zero or one on each of the disks. The...

2014-04-26 15:34:00 153

Timus 1131. Copying 数学公式的构造

A new educating program was received by the kindergarten. Of course, children have discovered it immediately and want to play with it as soon as possible. In order to let them do it the program ha...

2014-04-26 14:25:00 119

Timus 1837. Isenbaev's Number 图论 题解

Vladislav Isenbaev is a two-time champion of Ural, vice champion of TopCoder Open 2009, and absolute champion of ACM ICPC 2009. In the time you will spend reading this problem statement Vladislav ...

2014-04-26 13:19:00 149

Gray Code -- LeetCode

原题链接:http://oj.leetcode.com/problems/gray-code/这道题要求求出n位的格雷码对应的二进制数,主要在于找到一种格雷码的递增方法(格雷码并不是唯一的,可以有多种)。我们来看看有了n-1位的格雷码如何得到n位的格雷码呢?其实方法比较简单,首先在n-1位的格雷码前面都添加0作为前2^(n-1)个格雷码,它们一定是合法的因为除了第一位(都是0)其余位都跟n-1的格...

2014-04-26 06:22:00 160

Binary Tree Zigzag Level Order Traversal -- LeetCode

原题链接:http://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/这道题其实还是树的层序遍历Binary Tree Level Order Traversal,如果不熟悉的朋友可以先看看哈。不过这里稍微做了一点变体,就是在遍历的时候偶数层自左向右,而奇数层自右向左。在Binary Tree Level...

2014-04-26 04:31:00 170

Scramble String -- LeetCode

原题链接:http://oj.leetcode.com/problems/scramble-string/这道题看起来是比较复杂的,如果用brute force,每次做切割,然后递归求解,是一个非多项式的复杂度,一般来说这不是面试官想要的答案。这其实是一道三维动态规划的题目,我们提出维护量res[i][j][n],其中i是s1的起始字符,j是s2的起始字符,而n是当前的字符串长度,res[i][j...

2014-04-26 02:50:00 154

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 o...

2014-04-25 18:41:00 166

空空如也

空空如也

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

TA关注的人

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