摘要: 经典问题走的方向确定,如dir[][]所示。bfs 当搜到终点跳出View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<algorithm> 5 #include<queue> 6 using namespace std; 7 const int maxn = 10; 8 int mat[ maxn ][ maxn ]; 9 const int dir[8][2]={{2,1},{2,-1},{1,-2},{1,2},{-2 阅读全文
posted @ 2013-01-28 21:30 xxx0624 阅读(226) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include 2 #include 3 using namespace std; 4 const int maxn = 1005; 5 int a[ maxn ],dp[ maxn ];//dp[i]表示以a[i]结尾的子序列的和最大 6 int main(){ 7 int n; 8 while( scanf("%d",&n)!=EOF && n ){ 9 for( int i=0;i<n;i++ )10 scanf("%d",&a[ i ]);11 int ans=a[ 0 ];12 . 阅读全文
posted @ 2013-01-28 21:06 xxx0624 阅读(316) 评论(0) 推荐(0) 编辑
摘要: 将二维转化为一维。第一个FOR循环用于枚举 行,第二个和第三个FOR 用于求从当前行(J)开始的每一个矩阵方块和,从而得到ANS。View Code 1 #include<stdio.h> 2 #include<algorithm> 3 using namespace std; 4 const int maxn = 105; 5 int a[ maxn ][ maxn ],temp[ maxn ]; 6 int n; 7 8 int dp( ){ 9 int ans=temp[ 0 ];10 int tmp_sum=0;11 for( int i=0;i<n;i+ 阅读全文
posted @ 2013-01-28 20:46 xxx0624 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 详见代码View Code 1 /* 2 改变一个点,询问区间和 3 线段树 4 */ 5 #include<stdio.h> 6 #define lson l , mid , rt << 1 7 #define rson mid + 1 , r , rt << 1 | 1 8 const int maxn = 50005; 9 int sum[ maxn<<2 ],data[ maxn ];10 11 void PushUp( int rt ){12 sum[ rt ]=sum[ rt<<1 ]+sum[ rt<<1 | 阅读全文
posted @ 2013-01-28 17:34 xxx0624 阅读(483) 评论(0) 推荐(0) 编辑
摘要: lazy思想当一个数开了6到7次根号时,就变成1了。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #include<algorithm> 5 #include<math.h> 6 using namespace std; 7 typedef __int64 int64; 8 #define L( x ) (x<<1) 9 #define R( x ) ((x<<1)+1)10 const int64 maxn 阅读全文
posted @ 2013-01-28 17:32 xxx0624 阅读(1876) 评论(0) 推荐(0) 编辑