上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 25 下一页
摘要: 设串C的第一个字母在串A中出现的位置是stA, 串C的最后一个字母在串A中出现的位置是edA。设串C的第一个字母在串B中出现的位置是stB, 串C的最后一个字母在串B中出现的位置是edB。求出每一对合法的(stA, edA),(stB, edB)对每一组( stA[i], edA[i] ) 和 ( stB[j], ed[j] ), 求串A[0,stA[i]-1]和串B[0, stB[j]-1]的最长公共子序列长度L1,求串A[edA[i]+1, lenA-1]和串B[stB[j]+1, lenB-1]的最长公共子序列长度L2, 答案为max( lenC+L1+L2 )……现在看看自己赛场上写的 阅读全文
posted @ 2013-08-15 23:04 冰鸮 阅读(325) 评论(0) 推荐(0)
摘要: 负载是否平衡只与前两列有关,剩下的只要与前两列不重复就随便放。第一列我们按1-n这样循环放,第二列每次找个数最少的那个服务器放。#include #include #include using namespace std;const int MAXN = 110;int N, M;int mat[MAXN][MAXN];int cnt[MAXN];int ori[MAXN];bool vis[MAXN];void show(){ for ( int i = 1; i N ) j = 1; } solved(); show(); } ... 阅读全文
posted @ 2013-08-15 21:32 冰鸮 阅读(178) 评论(0) 推荐(0)
摘要: 1.三角形的所有端点2.过所有三角形的端点对所有圆做切线,得到所有切点。3.做任意两圆的外公切线,得到所有切点。对上述所有点求凸包,标记每个点是三角形上的点还是某个圆上的点。求完凸包后,因为所有点都是按逆时针(或顺时针)排好序的,如果相邻两点在同一圆上,那么求这段圆弧的距离,否则求这段直线的距离。最后得到所有周长。#include #include #include #include #include using namespace std;const double eps = 1e-9;const double PI = acos(-1.0);const int MAXN = 60;stru 阅读全文
posted @ 2013-08-15 21:27 冰鸮 阅读(3750) 评论(0) 推荐(0)
摘要: 参考了官方题解给的方法:对于处理循环,官方给了一种很巧妙的方法:#include #include #include #define LL long long intconst int MAXN = 50010;const int MAXMOD = 210;int N, K;int dp[MAXN][MAXMOD];int val[MAXN];int fac[MAXN 0; --i ) { sum = ( val[i] * fac[totL] + sum ) % K; totL += len[ val[i] ]; ... 阅读全文
posted @ 2013-08-14 10:15 冰鸮 阅读(473) 评论(0) 推荐(0)
摘要: pick定理:一个计算点阵中顶点在格点上的多边形面积公式:S=a+b÷2-1,其中a表示多边形内部的点数,b表示多边形边界上的点数,s表示多边形的面积。思路:http://blog.csdn.net/magicnumber/article/details/6192242#include #include #include #include #define LL long long intusing namespace std;const int MAXN = 1000100;const LL dx[] = { 0, -1, -1, -1, 0, 1, 1, 1 };const LL 阅读全文
posted @ 2013-08-13 10:57 冰鸮 阅读(244) 评论(0) 推荐(0)
摘要: 裸线段树,不过不是很好写,需要注意的地方挺多的。用sum[0],sum[1],sum[2]分别记录一次方和,平方和和立方和,更新的时候推一个增量公式:一次方:sum[0]+=(r - l + 1)*c;二次方: ∵(a+b)2=a2+2*a*b+b2; ∴ (xl+c)2 + (xl+1+c)2+……+(xr+c)2=xl2+xl+12+……+xr2+2*c*(xl+xl+1+……+xr)+(r-l+1)*c2; ∴ sum[1] = sum[1]+2*c*sum[0]+(r-l+1)*c2;(注:此处的sum[0]是未更新前的sum[0])三次方: ∵(... 阅读全文
posted @ 2013-08-13 09:48 冰鸮 阅读(511) 评论(0) 推荐(0)
摘要: 解法参考:http://blog.csdn.net/a601025382s/article/details/9840125#include #include #include #include using namespace std;#define LL long long intconst int MAXN = 1000010;const LL MOD = (1e9) + 7;int n;LL a[MAXN];LL b[MAXN];void ExGcd( LL a, LL b, LL& d, LL& x, LL& y ){ if ( !b ) { d = a, x = 阅读全文
posted @ 2013-08-09 17:11 冰鸮 阅读(274) 评论(0) 推荐(0)
摘要: 显然正着倒着看仍然是数字的只有7个数:0,1,2,5,6,8,9所以就是用这7个数组合成不同的数。将n转换成7进制,对应位输出即可。#include #include #include #include using namespace std;const char num[] = "0125986";const int MAXN = 1010;const int BASE = 7;char str[MAXN];int a[MAXN];int b[MAXN];int ans[MAXN];int cnt, len;bool check(){ for ( int i = 0; i 阅读全文
posted @ 2013-08-09 16:27 冰鸮 阅读(310) 评论(0) 推荐(0)
摘要: 跟矩阵链乘同类型的题……输出用%llu不是%I64u……几组数据:141+2*4+3*4+5*00*5*6+7*3+23+0+6+7+0+44*5+7*1*1+12*0+3*4*0+5*6+7+81+2+3*1+2*1+00+2*2+3*0+48*9*0+22*0+1+0*32*0*3+7+1*0*31+3*0*5+21+1+1+1+12*1+1+2*1+2*1+61*2*4*0*6*3#include #include #include #include #include #define LL unsigned long long intusing namespace std;const i 阅读全文
posted @ 2013-08-09 15:02 冰鸮 阅读(398) 评论(0) 推荐(0)
摘要: 每层找一对相等的整数,分别放在两个不同的串中。参考了学弟的解法,果断觉得自己老了……#include #include #include const int MAXN = 2010;int n;int num[MAXN];int vis[MAXN];bool DFS( int st, int last, int cur ){ if ( cur == n / 2 ) return true; for ( int i = st; i last ) { vis[j] = 1; if... 阅读全文
posted @ 2013-08-08 19:41 冰鸮 阅读(356) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 25 下一页