摘要:
http://poj.org/problem?id=3663二分查找 1 #include 2 #include 3 4 int a[20020]; 5 6 int bs(int l, int r, int v) 7 { 8 int m; 9 while(l > 1;12 if(a[m] < v)13 {14 l = m + 1;15 }16 else17 {18 r = m;19 }20 }21 return ... 阅读全文
摘要:
http://poj.org/problem?id=3664水题 1 #include 2 #include 3 4 using namespace std; 5 6 map, int> map1; 7 map, int>::iterator it; 8 9 int main()10 {11 int n, k;12 int i, x, y, max1, flag1, temp;13 while(~scanf("%d%d", &n, &k))14 {15 map1.clear();16 max1 = 0;17 ... 阅读全文
摘要:
http://poj.org/problem?id=3659树状DP,树的最小点覆盖 1 #include 2 #include 3 #define N 10010 4 5 using namespace std; 6 7 vector a[N]; 8 int mark[N], dp[N][3]; 9 const int inf = 12345678; 10 11 int min(int x, int y) 12 { 13 return xinf? inf: x; 19 } 20 21 int f(int x, vector b) 22 { 23 ... 阅读全文
摘要:
http://poj.org/problem?id=3668水题,STL 1 #include 2 #include 3 4 using namespace std; 5 6 set > set1; 7 8 int gcd(int x, int y) 9 {10 return y? gcd(y, x%y): x;11 }12 13 int abs(int x)14 {15 return x<0? -1*x: x;16 }17 18 struct P19 {20 int x, y;21 }p[1234];22 23 int main()24 {25 in... 阅读全文
摘要:
http://poj.org/problem?id=3670DP,最长不降子序列,O(n*logn)解法 1 #include 2 #define N 30030 3 4 int n, a[N], dp[N]; 5 const int maxint = (1>1;13 if(dp[m] maxn)35 {36 maxn ++;37 dp[maxn+1] = maxint;38 }39 }40 return maxn;41 }42 43 int main()44 {45 ... 阅读全文