摘要: 需要记得开一个数组存储数据以节省查询时间。。输入输出printf,scanf是必须滴。(这一次是数据小)#include<iostream>using namespace std;typedef long long int llint;const llint MAXN=100003;llint tree[MAXN];llint value[MAXN];llint lowbit(llint idx){ return idx & (-idx);}void add(llint pos, llint inc,llint n){ for (llint i = pos; i <= 阅读全文
posted @ 2012-08-04 19:29 77695 阅读(345) 评论(0) 推荐(0) 编辑
摘要: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1、2、3、4、5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY Huffman编码1013 STAMPS 搜索or动态规划1014 Border 模拟题1015 Simple Ar 阅读全文
posted @ 2012-08-02 19:45 77695 阅读(2275) 评论(0) 推荐(1) 编辑
摘要: 看队友ac了这个。。加上很久没写过深搜了。。手痒了。。遂拿之解闷~~一开始超时。。玩命的超时(这次用的printf了)。。查之发现二逼了代码在已经搜过的位置重复搜了几次。。导致代码目测时间复杂度为o(n!)。。玩命啊。。改之。。wa。。顿时想起以前做过之一题目。。即在搜索过程中搜不成功还得回溯。。遂改方法。。ac~#include<iostream>#include<algorithm>using namespace std;const int MAXM=22;int m;int num[MAXM];bool vis[MAXM];bool cmp(int a,int b 阅读全文
posted @ 2012-08-02 16:24 77695 阅读(2071) 评论(0) 推荐(0) 编辑
摘要: 题目就是一个大数模版。。但这道题目对输出的的格式要求很高。。它要求在每两个case之间加一个空行。。所以。。见代码把。。用到了大数模版。。见这http://www.cnblogs.com/cj695/archive/2012/07/28/2613678.htmlint main(){ int t; cin>>t; int i=1; for(i=1;i<=t;i++) { bignum a,b; cin>>a>>b; if(i!=1)cout<<endl; cout<<"Case "<<i<& 阅读全文
posted @ 2012-08-02 10:55 77695 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 依旧没弄懂。。先会用模版再说。。注意讨论(ans==-1)的情况#include<iostream>#define llint long long intusing namespace std;const int MAXM=12;llint exgcd(llint a, llint b, llint &x, llint &y){ if(b == 0){ x = 1, y = 0; return a;} llint r = exgcd(b, a % b, x, y); llint tmp = x; x = y; y = tmp - a/b * y; return r; 阅读全文
posted @ 2012-08-02 10:23 77695 阅读(743) 评论(0) 推荐(0) 编辑
摘要: 通过这道题目我们更加可以看清楚sg函数中的图的一些性质。。#include<iostream>#include<vector>using namespace std;const int MAXN=1002;vector<int>v[MAXN];int dp[MAXN];int sg(int p){ if(dp[p]!=-1) { return dp[p]; } int i; bool visited[MAXN]; memset(visited,0,sizeof(visited)); for(i=0;i<=int(v[p].size())-... 阅读全文
posted @ 2012-08-01 14:16 77695 阅读(621) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;const int MAXN=12;const int MOD=9973;struct matrix{ int data[MAXN][MAXN]; int n; void init() { int i,j; for(i=0;i<=MAXN-1;i++) { for(j=0;j<=MAXN-1;j++) { data[i][j]=0; } } ... 阅读全文
posted @ 2012-08-01 14:14 77695 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 用sg函数对每组数据中所有的数处理。。得到的结果异或。为0必输。。否则必胜#include<iostream>//#include<algorithm>#include<set>#include<cstdio>using namespace std;//const int MAXK=102;const int MAXM=102;//const int MAXL=102;const int MAXH=10002;set<int>de;int dp[MAXH];inline int sg(int cur){ if(dp[cur]!=-1) 阅读全文
posted @ 2012-08-01 14:12 77695 阅读(895) 评论(0) 推荐(0) 编辑
摘要: 按理来说应该会有二维的树状数组的算法吧。。可是我不知道。。于是就用一维的方式在累加了。。时间复杂度大概在o(m*n*log(n))。。直接暴力是o(m*n^2)#include<iostream>using namespace std;const int MAXN=1003;int data[MAXN][MAXN];void swap(int &a,int &b){ int t; t=a; a=b; b=t;}int lowbit(int idx){ return idx & (-idx);}void add(int x,int y,int inc,int 阅读全文
posted @ 2012-08-01 14:02 77695 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 一段这样的代码。。 switch(c) { int x1,y1,x2,y2,n1; case 'S': int suum=0; cout<<suum<<endl; break; }看似没错对吧。。但在devc++里面无法编译通过。。提示错误:error: jump to case label问题其实很简单就是一个变量的作用域的问题只需... 阅读全文
posted @ 2012-08-01 10:59 77695 阅读(1042) 评论(0) 推荐(0) 编辑