上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2065矩阵乘法推出递推公式。View Code Matrix tmp(4,4);void get_init() { int i,j,k; for(i=0;i<4;i++) for(j=0;j<4;j++) tmp(i,j)=1; for(i=0;i<4;i++) tmp(i,i)=2, tmp(i,3-i)=0;}void solve() { int i,j,k; Matrix ans(1,4), tt=tmp; ans(0,0)=ans(0,3)=1; ans(0,... 阅读全文
posted @ 2013-04-11 21:10 zhang1107 阅读(187) 评论(0) 推荐(0) 编辑
摘要: View Code const int maxn = 22; //矩阵大小struct Matrix { int r, c; //矩阵大小 int a[maxn][maxn]; //初始化 Matrix(int r,int c):r(r), c(c) {} void reset() {memset(a,0,sizeof(a));} //重写(),方便存取 int& operator() (int i,int j) {return a[i][j];} //O(N^3) 矩阵乘法 Matrix operator*(const Matrix&B)... 阅读全文
posted @ 2013-04-11 18:26 zhang1107 阅读(219) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4973推出递推公式, 数据范围那么大, 矩阵乘法。View Code const int MM = 100011;const double eps = 1e-10;#define maxint 10000000#define mod 1000000007#define debug puts("wrong");//typedef __int64 int64;typedef long long int64;//const __int64 maxint = 10 阅读全文
posted @ 2013-04-11 18:25 zhang1107 阅读(135) 评论(0) 推荐(0) 编辑
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1057View Code const int MM = 22222;int64 L, R, K, B, len;int64 C[33][33];int64 p[111];void get_p() { int64 i,j,k; p[0]=1; len=(int64)((log(1.0*R)/log(1.0*B))+1.0);// printf("%d\n",len); for(i=1;i<=len;i++) p[i]=p[i-1]*B;// for(i=0;i<=l 阅读全文
posted @ 2013-04-08 14:40 zhang1107 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 类似贪心。http://acm.nbu.edu.cn/v1.0/Problems/Problem.php?pid=2410View Code const int MM = 22222;int N,M;int cnt;int num[MM];struct Info { int val; int id; void reset() { val=maxint; id=-1; } bool friend operator<(Info x,Info y) { if(x.val!=y.val) return x.val<y.val; e... 阅读全文
posted @ 2013-04-01 21:58 zhang1107 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Gao The Sequence计算出一个差值数组C[i], 一种操作, 找一个delate有C[i]-=delaie,找任意多个C[j]-=D[j] (j<i) 使sum(D[j])=delate, 问能否使C[i]全部赋0.View Code #include<cstdio>#define ll long longint main(){ int n; while(~scanf("%d",&n)){ ll a,b,c,s=0,m=0; while(n--){ scanf("%lld%lld",&a,&b); . 阅读全文
posted @ 2013-04-01 13:35 zhang1107 阅读(195) 评论(0) 推荐(0) 编辑
摘要: DFS的过程中引用一个指针对数组的引用是很不靠谱的, 以后要引用, 尽量传一个值, 类似于用结构体, 封装一个数组。http://acm.hdu.edu.cn/showproblem.php?pid=4536View Code const int MM = 22222;int N,M, Q;struct Info { int belong[22]; int val[22];}p;vector<int>B[MM];int ret,g;int a[5][MM];Info t;void get_data() { int i,j,k; scanf("%d%d%d",&a 阅读全文
posted @ 2013-04-01 13:03 zhang1107 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 线段树维护区间最小值, 简单记录下, 下标写错啦, WA到死。http://acm.hdu.edu.cn/showproblem.php?pid=4544View Code #include <iostream>#include <cstdio>#include <cstring>#include <algorithm>int f_min(int x,int y) {return x>y?y:x;}int f_max(int x,int y) {return x>y?x:y;}int f_abs(int x) {return x> 阅读全文
posted @ 2013-03-31 23:43 zhang1107 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 类似与快速幂的做法View Code /*===================================================================*\ | 两个数相乘超long long乘法的取模 mod的大小要十分注意\*===================================================================*/int multi_mod(int a,int b,int c) { //(a*b)%c int ret=0; while(b) { if(b&1) { ret+=a; if(re... 阅读全文
posted @ 2013-03-31 11:09 zhang1107 阅读(1736) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/problemset/problem/38/EDP状态很容易想到,以后超long long 最大值的设定最好计算出一个边界, int_max的边界赋值 错误,导致WA那么多次。View Code #include <iostream>#include <cstdio>#include <vector>#include <cmath>#include <set>#include <map>#include <queue>#include <fstream># 阅读全文
posted @ 2013-03-29 14:23 zhang1107 阅读(292) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 22 下一页