05 2013 档案
摘要:http://wenku.baidu.com/view/25540742a8956bec0975e3a8.htmlhttp://wenku.baidu.com/view/03fd09ded15abe23482f4d81.html
阅读全文
摘要:http://acm.sgu.ru/problem.php?contest=0&problem=542
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3436
阅读全文
摘要:const int MM = 1000+5;#define debug puts("wrong") #define inf 1000000 #define mod 1000000007 int N,M,K, L;int g=1; void printcase() {printf("Case %d: ",g++);}struct Point{ int x,y,r; bool friend operator<(Point a,Point b) { return a.r<b.r; } }num1[MM],num2[MM];Point start,
阅读全文
摘要:http://www.cs.cmu.edu/~sleator/papers/dynamic-trees.pdf单词背的再快也看不懂
阅读全文
摘要:对于每首歌拆成左边和右边两组点,对于每个人擅长的歌曲,就从这个人往右边的点连边,否则连向左边的点,因为不擅长的歌最多有K个人唱,所有左边向右边连容量为K的边,然后二分最大的天数,如果对于每个天数都分派的过来的话,则是可行的一组解。
阅读全文
摘要:x1+x2+........+xk=N1x1+2x2+........+kxk=N求所有满足条件的sum(mul(xi))
阅读全文
摘要://Ctrl+D 删除//RGB颜色对照 "#000000"->black "#00FF00"->greenandroid:inputType="number" //限制输入的是数字android:hint="I'm EditText" //显示提示信息//在drawable-mdpi中导入png格式的图片,图片名称为baiandroid:drawableLeft="@drawable/bai" //引用图片//在drawable-mdpi中创建xml文件shape
阅读全文
摘要://Alt + ?实现代码的自动补全//res/values/strings.xml 目录下面实现类似于c++的宏定义<string name="hello">Hello Notebook!!</string><TextView android:text="@string/hello" />//显示的是调用的内容android:textSize="20sp" //字体大小用sp作为单位,宽度,高度用dpandroid:textColor="#00FF00"//设置字体颜色为绿色a
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3541http://blog.csdn.net/kang205/article/details/6305159
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4556//就是求有多少个分数,对于分母i求N以内与其互质的数的个数,其实就是欧拉函数const int MM = 1000000+10;typedef __int64 ll; int N; ll phi[MM], sum[MM];void get_phi() { ll i,j,k; for(i=1;i<MM;i++) phi[i]=i; for(i=2;i<MM;i+=2) phi[i]>>=1; for(i=3;i<MM;i++) { if(phi[i]==i...
阅读全文
摘要:参考:http://baike.baidu.com/view/5221.htmView Code //5个海盗抢得100枚金币,他们按抽签的顺序依次提方案:首先由1号提出分配方案,然后5人表决,超过半数同意方案才被通过,否则他将被扔入大海喂鲨鱼,问第一个海盗用最小的代价使利益最大化。// 从后向前推,如果1至3号强盗都喂了鲨鱼,只剩4号和5号的话,5号一定投反对票让4号喂鲨鱼,以独吞全部金币。所以,4号惟有支持3号才能保命。// 3号知道这一点,就会提出“100,0,0”的分配方案,对4号、5号一毛不拔而将全部金币归为已有,因为他知道4号一无所获但还是会投赞成票,再加上自己一票,他的方案即可通
阅读全文
摘要:http://wenku.baidu.com/view/42f126fff705cc1755270925.html欧几里得http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibmaths.htmlhttp://www.doc88.com/p-725223432206.htmlFibonaccihttp://blog.csdn.net/acmaker/article/details/3178696旋转卡壳
阅读全文
摘要:http://www.codeforces.com/contest/301/problem/DN个数M个查询(1~10^5),每次查询求[L,R]区间内一个数是另一个数除数的数对有多少。比如:10 9 1 2 3 4 5 6 7 8 9 10 1 10ans = 27http://www.codeforces.com/problemset/problem/306/C南京邀请赛F:http://icpc.njust.edu.cn/Local/1742http://wjmzbmr.com/archives/xiaoqiang_pyramid/http://codeforces.com/proble
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4317有可能error串包含相互的error串,所以建立fail的时候val的标记也要相互转移。View Code typedef long long ll;ll N;#define mod 1000000009 #define debug puts("wrong");#define ROOT 0const int MAX_NODE=2222;//stringnum*stringlenconst int CHI=2; //儿子数ll dp[222][MAX
阅读全文
摘要:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=20333#problem/A
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3975View Code
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1837有dp[floor]=sum{dp[floor+i]/6}+1 (1<=i<=6) 可以列出方程,方向分up和down讨论View Code
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4712View Code int N,M;//注意题目说x为正整数,0不算int Extend_euc(int a,int b,int&x,int&y) { if(b==0) {x=1,y=0;return a;} int d=Extend_euc(b,a%b,x,y); int tmp=x; x=y; y=tmp-(a/b)*y; return d;}void modeq(int a,int b,int n) { int e,i,d,x,y,t...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showSubmission.do?submissionId=3568082View Code //确定king只有一个后可以在O(N)解决每次询问const int MM = 331630;const int maxn = 31;typedef long long int64;#define debug puts("wrong"); int N,M,Q;char ss[MM][100];set<pair<int,int> >sbt;map<string,int>mp;m
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2685
阅读全文
摘要:http://poj.org/problem?id=1811View Code /*=====================================================*\| Miller Rabin 判断一个大数是不是素数 | Pollard 找出因子\*=====================================================*/#define inf 0x3f3f3f3f#define linf inf*inf#define SS 8//Miller测试次数#define C 240typedef long long ll;ll N,
阅读全文
摘要:http://poj.org/problem?id=3678典型的2-sat裸题View Code /*====================================================*\| 2-sat问题:判断某个数的0或1的取值是否存在满足条件的解\*====================================================*/const int MM = 222222;int N, M;bool inq[MM];int cur,cnt,belong[MM];int stack[MM], top,dfn[MM], low[MM];int
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3216View Code //复杂度O(sqrt(N)),蛮有意思的const int MM = 11111;typedef long long int64;int64 N;void solve() { int64 i,j,k,sum=0,tmp; scanf("%lld",&N); for(i=1;(i*i)<=N;i++) { tmp=N/i; sum=sum+i*(N/i-N/(i+1)); if(tmp!=i...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3221View Code //逆推const int MM = 1111111;#define debug puts("wrong")//typedef __int64 int64;const double lep=1e-10;int N,M, n,m;map<vector<int>,bool>mp;vector<int>st;vector<int>en;void get_data() { int i,j,k
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3221对于指数取欧拉函数需要注意一下,a^x%P=a^(x%phi(P)+phi(P))%PView Code //A^x = A^(x % Phi(C) + Phi(C)) (mod C) 的应用const int MM = 1111111;#define debug puts("wrong")typedef __int64 int64;const double lep=1e-10;int64 a,b,P,n,mod;const int maxn = 3; //矩阵大小struct Ma
阅读全文
摘要:http://acm.fzu.edu.cn/problem.php?pid=1759View Code //A^x = A^(x % Phi(C) + Phi(C)) (mod C) 的应用const int MM = 1111111;#define debug puts("wrong")typedef __int64 int64;const double lep=1e-10;int64 N,mod; char str[MM];int64 euler(int64 x) { int64 i, res=x; for(i=2;(i*i)<=x;i++) { if(x%i==
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1556View Code //区间标记, 当然对于任意修改都能做const int MM = 111111;#define debug puts("wrong")const double lep=1e-10;int N,num[MM];void solve() { int i,j,k,x,y; memset(num,0,sizeof(num)); for(i=0;i<N;i++) { scanf("%d%d",&x,&y); num[x]++, n
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1686View Code //存在到0边的奇数步的路,则先手胜const int MM = 11111;#define inf 0x3f3f3f3f#define debug puts("wrong")typedef long long int64;int N,M;int num[MM];void get_data() { int i,j,k; scanf("%d",&N); for(i=0;i<N;i++) scanf(
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1684View Code //重新建树,求两点间最短距离const int MM = 11111;#define inf 0x3f3f3f3f#define debug puts("wrong")typedef long long int64;int num[MM], N, tot;int chd[MM], len; //节点的儿子个数bool vis[MM];vector<int>edge[MM];struct Info{int node,s
阅读全文
摘要:View Code const int maxn = 111; //方程大小int m, n; // 行号 列号double a[maxn][maxn], x[maxn]; //x为结果void Gauss() { double d = 0, t = 0, sum = 0; int k = 1, l = 0, i = 0, j = 0; while (k <= n) { //*****选主元素***** d = a[k][k]; l = k; ...
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2838View Code //对于x,y,z树上的位置进行分类讨论/* z z t t /\ / /\ /\ x y t z y x z /\ / \ x y x y*/const int MM = 55555;int N, M;vector<...
阅读全文
摘要:http://poj.org/problem?id=1330View Code const int MM = 22222;int N, in[MM], root;int head[MM],NE;struct Edge{ int u,v,next;}edge[MM];bool vis[MM];int ief,level;int dp[MM][17]; //节点数*2int E[MM], L[MM], H[MM]; //节点数*2int log_2(int x) { int res=-1; while(x) x>>=1,res++; return res;}void add...
阅读全文
摘要:http://poj.org/problem?id=3420View Code //矩阵乘法做递推Matrix mat(16,16);void get_init() { mat.reset(); mat(0,15)=mat(1,14)=mat(2,13)=1; mat(3,12)=mat(3,15)=mat(4,11)=1; mat(5,10)=mat(6,9)=mat(6,15)=1; mat(7,8)=mat(7,14)=mat(7,11)=1; mat(8,7)=mat(9,6)=mat(10,5)=1; mat(11,4)=mat(11,7)=...
阅读全文
摘要:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34348View Code const int MM = 11111;#define debug puts("wrong")//typedef __int64 int64;int p[MM]={1,2,5,10,20,50,100,200};int num[MM], g[MM], gg[MM];int N,M,sum=0;void get_data() { int i,j,k; for(i=sum=0;i<8;i++) { scanf("
阅读全文
摘要:View Code #define ROOT 0const int MAX_NODE=100100;//stringnum*stringlenconst int CHI=26; //儿子数struct ACtree { int size; int hash[300]; int val[MAX_NODE]; int fail[MAX_NODE]; int SQ[MAX_NODE]; int chd[MAX_NODE][CHI]; void get_hash() { int i,j,k; for(i=0;i<CHI;i++) ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1545View Code const int MM = 11111;#define debug puts("wrong")typedef __int64 int64;int N,M;int64 dp[63][11][11];//j min(0-1) k max(0-1)void solve() { int i,j,k;int64 tmp,t1,t2; memset(dp[0],0,sizeof(dp[0])); dp[0][M][M]=1; for(i=1;i<=N;i++) { .
阅读全文
摘要:http://poj.org/problem?id=2186View Code const int MM = 11111;#define debug puts("wrong")typedef __int64 int64;int N,M;vector<int>edge[MM];const int maxn = 11111; //节点数bool instack[maxn];int ief,top,bcnt,st[maxn];int low[maxn],dfn[maxn],belong[maxn];int out[MM];void get_data() { int i
阅读全文
摘要:View Code //Raney引理:设整数序列A={Ai,i=1,2,...,N},且部分和为Sk=A1+,...,+Ak,序列中的所有的数字之和为Sn=1; 则在A的N个循环表示中,有且仅有一个序列B,满足B的任意部分和Si均大于零。//证明由于Sn=1,则Sk+Sn=Sk+1,存在这样一个数x,当在x和x+1之间的某点过后,其后所有的点都在0以上。 //序列// 一个序列{Ai,i=0,1,2,....,3n},由 3n+1项组成,每一项是1或-2。定义部分和Sk=A0+A1+...+Ak,求所有满足S3n=1,而且对k=0,1,...3n,Sk>0,的序列的个数。// ...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1544View Code
阅读全文
摘要:http://poj.org/problem?id=2663View Code //放骨牌类问题,dfs枚举方法,递推。 const int MM = 1111;#define debug puts("wrong")typedef __int64 int64;int64 N,M,dp[111][11];void dfs(int64 row,int64 col,int64 pre,int64 now,int64 ss) { if(col>=3) { if(pre==7) dp[row][now]+=ss; return; } if((pre&(1<<
阅读全文
摘要:http://poj.org/problem?id=1095catalan数确定N个节点的二叉树的种数,左右分配节点确定id。View Code const int MM = 11111;const int maxn = 19;typedef __int64 int64;#define debug puts("wrong")int N;int cata[maxn];void get_cata() { int i,j,k; cata[0]=cata[1]=1; for(i=2;i<maxn;i++) { for(cata[i]=0,j=0;j<i;j++) cat
阅读全文
摘要:http://acm.fzu.edu.cn/problem.php?pid=2113枚举1的个数,ans=ans+i*dfs();View Code const int MM = 11111;typedef __int64 int64;#define debug puts("wrong")int cnt, num[MM];int64 dp[20][20][20],L,R;int64 dfs(int le,int sum,int s,bool less) { if(le==-1) return sum==s; if(!less && dp[le][sum][s
阅读全文
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3416注意当0也是满足条件的情况下, 假设数字分解有cnt位,则结果将会多出cnt-1个0,即ans-cnt+1为最后结果。View Code
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4352类似于O(nlog n)的LIS求法,用1<<10记录10以内数的出现情况,贪心更新。View Code //类似于O(nlog n)的LIS求法,用1<<10记录10以内数的出现情况,贪心更新。const int MM = 11111;typedef __int64 int64;int K,cnt, num[MM];int64 dp[20][1<<10][10],L,R;void get_data() { scanf("%I64d%I64d%d"
阅读全文
摘要:find a+b+c=d , 3sum problem 枚举dhttp://poj.org/problem?id=2549View Code const int MM = 111111;int N;int num[MM];void get_data() { int i,j,k; for(i=0;i<N;i++) scanf("%d",&num[i]);}//choose three number from a set,then a+b+c=0void threesum(int n,int*val) { int i,j,k,a,b,c,tmp,l; sort(v
阅读全文
摘要:参考:http://en.wikipedia.org/wiki/3SUM//choose three number from a set,then a+b+c=0View Code //choose three number from a set,then a+b+c=0//其实就是两头逼近,复杂度O(N^2)void threesum(int n,int*val) { int i,j,k,a,b,c,tmp,l; sort(val,val+n); for(i=0;i<n-2;i++) { a=val[i], j=i+1, k=n-1; while...
阅读全文
摘要:资料:http://wenku.baidu.com/view/1845fdc75fbfc77da269b1ae.html http://wenku.baidu.com/view/e7c220c52cc58bd63186bdae.html
阅读全文