原创 HDU 1542(Atlantis)
#include <iostream> #include <algorithm> #include <iomanip> using namespace std; const int MAXN = 205; struct Line {
原创 HDU 1569(方格取數(2))
#include <cstdio> #include <cstring> #include <queue> #include <algorithm> using namespace std; const int MAXN = 10005
原创 HDU 1570(A C)
基礎題。 #include <iostream> using namespace std; int main() { int T; cin >> T; while (T--) { char c; cin >> c;
原创 HDU 1568(Fibonacci)
#include <iostream> #include <cmath> using namespace std; int main() { int f[21] = { 0,1 }; //前20個Fibonacci數
原创 HDU 1541(Stars)
#include <iostream> #include <cstring> using namespace std; const int MAXN = 32005; int tree[MAXN << 2], num[MAXN <<
原创 HDU 1567(2006)
基礎題,關鍵是理解題意,要求每一行的輸入爲每支隊伍比賽且僅比賽一次,輸出整個比賽安排是否合理。 #include <cstdio> #include <cstring> using namespace std; const int MA
原创 HDU 1565(方格取數(1))
#include <iostream> #include <algorithm> using namespace std; const int L = 20000; int n; int mp[25][25]; //地圖 int dp
原创 HDU 1564(Play a game)
找規律題,如果 n 爲偶數,先手贏;如果 n 爲奇數,後手贏。 #include <iostream> using namespace std; int main() { int n; while (cin >> n) {
原创 HDU 1562(Guess the number)
基礎題。 #include <iostream> using namespace std; int main() { int T; cin >> T; while (T--) { int a, b, c; cin >>
原创 HDU 1561(The more, The Better)
#include <iostream> #include <algorithm> using namespace std; const int MAXN = 205; struct Edge //邊 { int to; //到
原创 HDU 1563(Find your present!)
基礎題,使用 map 數據結構即可。 #include <iostream> #include <map> using namespace std; map<int, int> mp; int main() { int n; w
原创 HDU 1556(Color the ball)
使用差分數組即可。 #include <iostream> #include <cstring> using namespace std; const int MAXN = 100005; int t[MAXN]; //差分數組 i
原创 HDU 1551(Cable master)
基礎題,二分查找即可。 #include <iostream> #include <iomanip> using namespace std; const int MAXN = 10005; const double eps = 1e-
原创 HDU 1544(Palindromes)
基礎題,將原字符串中每一個字符作爲迴文子串的中心點,按照子串長度爲奇數和偶數向兩邊擴展即可。 #include <iostream> #include <string> using namespace std; int main()
原创 HDU 1559(最大子矩陣)
動態規劃題,設 dp[i][j] 表示從 (1, 1) 開始,i 行,j 列的矩陣元素之和,則 dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + num[i][j]。 每次輸入新元素時