原创 Poj 2406(同1961)

Description Given two strings a and b we define a*b to be their concatenat

原创 Poj 1961

問題描述 For each prefix of a given string S with N characters (each character

原创 Poj 2001 Shortest Prefixes

Description A prefix of a string is a substring starting at the beginning

原创 hiho 1344

題意:給一字符串中,任意單詞間沒有公共相同的字母,求滿足這樣的單詞的最大個數。 解析:貪心+暴力(可以用DFS) #include<cstdio> #include<cstring> #include<string> #include<i

原创 hdu 1503

題意:給定兩個字符串,合併成一個字符串,合併成的這個字符串同時也能分解成原來的兩個字符串。 解析:使用DP(LCS最長公共子序列),使用標記,不同的狀態,用不同的標記,將公共的字符輸出一次即可。 #include<cstdio> #inc

原创 Poj 3450

Description Beside other services, ACM helps companies to clearly state th

原创 hdu 2955

題意:有幾組測試用例,第一個小數,表示搶劫犯被抓的概率p,第二個數N表示下面有N個銀行,下面N行,每行第一個數表示銀行有多少錢,第二個數表示能抓住搶劫犯的概率。求在不被抓住的情況下能搶到最多的錢 解析:求反概率,即不被抓住的概率 #inc

原创 字符串模擬大數相加

#include<cstdio> #include<cstring> #include<algorithm> #include<string> using namespace std; const int maxn=100009; cha

原创 hdu 1423(最長公共上升子序列)

#include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; const int maxn=1009; int

原创 大數運算

#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<string> using namespace std; //兩個大數相

原创 hdu 2191

Input 輸入數據首先包含一個正整數C,表示有C組測試用例,每組測試用例的第一行是兩個整數n和m(1<=n<=100, 1<=m<=100),分別

原创 Poj 2002

題意:給一個數N,下面給N行,每行給一個X,Y,表示座標,求這些座標能組成正方形最大個數 解析: 先枚舉兩個點,通過數學公式得到另外2個點,使得這四個點能夠成正方形。然後檢查散點集中是否存在計算出來的那兩個點,若存在,說明有一個正方形。

原创 最長迴文子串

#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn=1000009; char str[maxn],ste[

原创 Poj 2752

Description The little cat is so famous, that many couples tramp over hill

原创 hdu: 4287

Problem Description   We all use cell phone today. And we must be familiar