原创 Sicily 1034 Forest

廣搜找森林的深度和寬度 #include <iostream> #include <memory.h> #include <vector> #include <deque> using namespace std; int is_visi

原创 Sicily 1077 Cash Machine

多重揹包問題 #include <stdio.h> #include <vector> #include <memory.h> using namespace std; int dp[100010]; vector<int> items;

原创 Sicily 1158 Pick numbers

廣搜找權值最小的路徑 #include <stdio.h> #include <memory.h> #include <deque> using namespace std; int matrix[12][12]; int n,m; st

原创 Sicily 1685 Missile

DP,最長單調子序列的變形。 #include <stdio.h> int dp[1010][2]; int nums[1010]; int get_max(int a, int b) { if (a>b) return a; e

原创 POJ題目分類

獻給有志於認真學習算法的同學!!! POJ上的一些水題(可用來練手和增加自信) (poj3299,poj2159,poj2739,poj1083,poj2262,poj1503,poj3006,poj2255,poj3094) 初期: 一

原创 LeetCode Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindr

原创 LeetCode Same Tree

Given two binary trees, write a function to check if they are equal or not.Two binary trees are consid

原创 LeetCode Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k

原创 LeetCode Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow

原创 LeetCode Convert Sorted List to Binary Search Tree

Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 把有序鏈表轉換爲二

原创 uva 231 Testing the CATCHER

題目很長,其實就是個最長單調子序列的問題。 #include <stdio.h> int data[1000]; int dp[1000]; int get_max(int a, int b) { if (a>b) return a

原创 UVA 103 Stacking Boxes

記憶化搜索 #include <stdio.h> #include <vector> #include <algorithm> #include <memory.h> using namespace std; struct Box {

原创 uva 190 Circle Through Three Points

計算幾何的題目,三點確定一個圓。 #include <stdio.h> #include <math.h> struct Line { int no_slope; double k; double i_x; double i_y;

原创 UVA 101 The Blocks Problem

直接模擬四個操作 #include <iostream> using namespace std; #include <vector> #include <string> vector<int> data[30]; int n; void

原创 uva 120 Stacks of Flapjacks

模擬題 #include <stdio.h> #include <vector> #include <algorithm> using namespace std; int ori[40]; int sorted[40]; int dat