原创 莫比烏斯函數 51Nod - 1240

莫比烏斯函數,由德國數學家和天文學家莫比烏斯提出。梅滕斯(Mertens)首先使用μ(n)(miu(n))作爲莫比烏斯函數的記號。(據說,高斯(Ga

原创 最長迴文子串 馬拉車算法

描述    小Hi和小Ho是一對好朋友,出生在信息化社會的他們對編程產生了莫大的興趣,他們約定好互相幫助,在編程的學習道路上一同前進。    這一天,他們遇到了一連串的字符串,於是小Hi就向小Ho提出了那個經典的問題:“小Ho,你能不能

原创 Coins POJ - 3210

Snoopy has three coins. One day he tossed them on a table then and tried to flip some of them so that they had eithe

原创 Coins POJ - 1742 多重揹包

People in Silverland use coins.They have coins of value A1,A2,A3...An Silverland dollar.One day Tony opened his money-

原创 To Add or Not to Add CodeForces - 231C 尺取

A piece of paper contains an array of n integers a1, a2, ..., an. Your task is to find a number that occurs the maxim

原创 L1-039. 古風排版

中國的古人寫文字,是從右向左豎向排版的。本題就請你編寫程序,把一段文字按古風排版。 輸入格式: 輸入在第一行給出一個正整數N(<100),是每一列的字符數。第二行給出一個長度不超過1000的非空字符串,以回車結束。 輸出格式: 按古風格

原创 統計難題 HDU - 1251 trie樹

Ignatius最近遇到一個難題,老師交給他很多單詞(只有小寫字母組成,不會有重複的單詞出現),現在老師要他統計出以某個字符串爲前綴的單詞數量(單詞本身也是自己的前綴). Input 輸入數據的第一部分是一張單詞表,每行一個單詞,單詞的

原创 L2-001. 緊急救援 SPFA+記錄路徑,統計最短路

作爲一個城市的應急救援隊伍的負責人,你有一張特殊的全國地圖。在地圖上顯示有多個分散的城市和一些連接城市的快速道路。每個城市的救援隊數量和每一條連接兩個城市的快速道路長度都標在地圖上。當其他城市有緊急求助電話給你的時候,你的任務是帶領你的

原创 機器人走方格 V2 51Nod - 1119 組合數學+逆元

M * N的方格,一個機器人從左上走到右下,只能向右或向下走。有多少種不同的走法?由於方法數量可能很大,只需要輸出Mod 10^9 + 7的結果。   Input 第1行,2個數M,N,中間用空格隔開。(2 <= m,n <= 10000

原创 Fliptile POJ - 3279 開關問題

Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brai

原创 Color the ball HDU - 1556 線段樹區間更新點查詢

N個氣球排成一排,從左到右依次編號爲1,2,3....N.每次給定2個整數a b(a <= b),lele便爲騎上他的“小飛鴿"牌電動車從氣球a開始到氣球b依次給每個氣球塗一次顏色。但是N次以後lele已經忘記了第I個氣球已經塗過幾次顏色

原创 How far away ? HDU - 2586 M次spfa

There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like

原创 codeforces 939 A Love Triangle

As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. The

原创 Safecracker HDU - 1015 DFS回溯 or 暴力

Safecrack === Op tech briefing, 2002/11/02 06:42 CST === "The item is locked in a Klein safe behind a painting in the

原创 Cash Machine POJ - 1276 多重揹包

A Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a reques