原创 Soldier and Badges(546B)

Colonel has n badges. He wants to give one badge to every of his n soldiers. Each badge has a coolness factor, which

原创 小孩報數問題(3750)

有N個小孩圍成一圈,給他們從1開始依次編號,現指定從第W個開始報數,報到第S個時,該小孩出列,然後從下一個小孩開始報數,仍是報到S個出列,如此重複下去,直到所有的小孩都出列(總人數不足S個時將循環報數),求小孩出列的順序。

原创 Snooker(2060)

*background: Philip likes to play the QQ game of Snooker when he wants a relax, though he was just a little vegetable-

原创 數塔(2084)

*在講述DP算法的時候,一個經典的例子就是數塔問題,它是這樣描述的: 有如下所示的數塔,要求從頂層走到底層,若每一步只能走到相鄰的結點,則經過的結點的數字之和最大是多少? 已經告訴你了,這是個DP的題目,你能AC嗎?   Input

原创 數據結構之堆棧計算器

注:支持+,-,*,/,(,),程序簡陋,請確保輸入正確的式子,不需要輸入等號 #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #inclu

原创 Big Number(1212)

As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a

原创 Parentheses Balance(673)

You are given a string consisting of parentheses () and []. A string of this type is said to be correct: (a)if it is t

原创 01-複雜度1. 最大子列和問題(20)

給定K個整數組成的序列{ N1, N2, ..., NK },“連續子列”被定義爲{ Ni, Ni+1, ..., Nj },其中 1 <= i <= j <= K。“最大子列和”則被定義爲所有連續子列元素的和中最大者。例如 給定

原创 01-複雜度2. Maximum Subsequence Sum (25)

Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } wh

原创 Robberies(2955)

The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the

原创 Jungle Roads(1301)

The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra ro

原创 Worm(2151)

*自從見識了平安夜蘋果的漲價後,Lele就在他家門口水平種了一排蘋果樹,共有N棵。 突然Lele發現在左起第P棵樹上(從1開始計數)有一條毛毛蟲。爲了看到毛毛蟲變蝴蝶的過程,Lele在蘋果樹旁觀察了很久。雖然沒有看到蝴蝶,但Lele發現

原创 配置cfree 5 支持C++11

最近想學c++的一些用法,但Cfree並不支持,所以在大牛的幫助下配置了一下cfree。 c-free5.0版本已經可以支持c99標準。由於CFree5.0自帶的GCC版本只有3.4.0,並不支持C++11,所以首先得去下載完整

原创 初學數據結構之排序

還在學習。學完再加 插入排序 void Insertion_Sort(int A[],int N) { int p,Tmp,i; for(p=1;p<N;p++) { Tmp=A[p]; for(i=p;i>0 && A

原创 快速排序(qsort and sort)

初學qsort,覺得排序函數還是十分麻煩的。 注意:1.qsort中用-,而sort中用<            2.qsort中最好用const void*a,const void*b,再強制轉換指針,而sort中可以用NODE a ,