上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 22 下一页
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=49950-1背包,按照时间排序保证总时间最小。以后写if-else注意多continue,还有0-1背包不需要多加一维。以后注意。View Code const int MM = 1111;#define debug puts("wrong")//typedef __int64 int64;int N,M;int dp[MM][4];struct Info{int t,v;}g[MM];bool cmp(Info x,Info y) {return x.t 阅读全文
posted @ 2013-04-26 13:47 zhang1107 阅读(171) 评论(0) 推荐(0) 编辑
摘要: http://www.nocow.cn/index.php/Treap_C%2B%2BView Code /*****************************************\treap完成插入,删除,查找第K个数询问x在序列中为名次,返回最小值\*****************************************/const int inf=~0U>>1;class treap { struct node { int value,key,size; node(int v,node*n):value(v) {c[0]=c[1]=n... 阅读全文
posted @ 2013-04-25 11:13 zhang1107 阅读(137) 评论(0) 推荐(0) 编辑
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1684kmpView Code const int MM = 1111111;#define debug puts("wrong")typedef __int64 int64;char str[MM], ch[MM];int n,m;int fail[MM], ans[MM], cnt;void get_next(int n) { int i, j=-1; for(fail[0]=-1, i=1;i < n; i++) { while(j>=0 && 阅读全文
posted @ 2013-04-24 22:49 zhang1107 阅读(144) 评论(0) 推荐(0) 编辑
摘要: http://acm.timus.ru/problem.aspx?space=1&num=1682记录取模的余数,并查集。View Code const int MM = 511111;#define debug puts("wrong")typedef __int64 int64;int64 N;bool vis[MM];vector<int64>g[MM];vector<int64>gg[MM]; //^2int64 fa[MM], ran[MM];int64 getfa(int64 x) {return x==fa[x]?x:fa[x] 阅读全文
posted @ 2013-04-24 22:44 zhang1107 阅读(159) 评论(0) 推荐(0) 编辑
摘要: View Code /*==================================================*\| 求解 C(n,m)%p 保证p为素数n很大10^9 m很小10^5\*==================================================*/typedef __int64 int64;int64 N,M, mod;int64 p[MM];void get_data() { int i,j,k; scanf("%I64d%I64d%I64d",&N,&M,&mod);}int64 exp_ 阅读全文
posted @ 2013-04-24 10:59 zhang1107 阅读(158) 评论(0) 推荐(0) 编辑
摘要: View Code /*==================================================*\| 比较高效的大数| < , <= , + , - , * , / , %(修改/的最后一行可得)\*==================================================*/const int maxn = 1111; //最大长度const int base = 10000; //%04dstruct bint { int ln, v[maxn]; bint (int r) { memset(v,0,size... 阅读全文
posted @ 2013-04-23 18:51 zhang1107 阅读(137) 评论(0) 推荐(0) 编辑
摘要: View Code inline bool scan_d(int &num) { // 外挂输入 char in;bool IsN=false; in=getchar(); if (in == EOF) return false; while (in!='-' &&( in<'0'||in>'9')) in=getchar(); if (in == '-') { IsN=true;num=0;} else num=in-'0'; while (in=getchar(),in> 阅读全文
posted @ 2013-04-20 19:33 zhang1107 阅读(110) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/problemset/problem/50/C记录出轮廓线,计算出走的长度, ans+4View Code void get_data() { int64 i,j,k; for(i=0;i<N;i++) scanf("%I64d%I64d",&g[i].x,&g[i].y);}void solve() { int64 i,j,k,x,y,ans=0,cnt; cnt=graham(g,N,res); for(i=1;i<cnt;i++) { // printf("%d %d\n",r 阅读全文
posted @ 2013-04-20 14:18 zhang1107 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Graham求凸包 O(N * logN)View Code /*==================================================*\| Graham求凸包 O(N * logN)| CALL: nr = graham(pnt, int n, res);|pnt[]为给定点集 n为点的个数 res[]为凸包点集;\*==================================================*/struct Tpoint {int x,y;}g[MM]; //注意点的类型Tpoint res[MM];bool mult(Tpoint 阅读全文
posted @ 2013-04-20 14:16 zhang1107 阅读(149) 评论(0) 推荐(0) 编辑
摘要: View Code //头文件:#include <algorithm>//O(N!)const int maxn = 1000; int num[maxn];void permut(int n) { //n:元素个数 int i,j,k; sort(num,num+n); //注意排序 do { for(i=0;i<n;i++) printf("%d ",num[i]); printf("\n"); }while(next_permutation(num,num+n));} 阅读全文
posted @ 2013-04-20 13:47 zhang1107 阅读(111) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 22 下一页