上一页 1 ··· 5 6 7 8 9
摘要: #include<stdio.h>int fa[50005]={0};int rank[50005]={0};int n;void initial(){ for(int i=1;i<=n;i++) { fa[i]=i; rank[i]=0; }}int getfather(int x){ if(x==fa[x]) return x; int oldfa = fa[x]; fa[x]=getfather(fa[x]); rank[x]=(rank[x]+rank[oldfa])%3; //用向量的形式很快就可以看出来 return... 阅读全文
posted @ 2013-03-12 21:28 YaLing 阅读(158) 评论(1) 推荐(0)
摘要: #include#includeusing namespace std;typedef struct Value{ int v,w; //v是价值 w是重量}Value;bool cmp(Value a,Value b) //按物品的价值从大到小排序{ return a.v>b.v||(a.v=... 阅读全文
posted @ 2013-03-12 19:50 YaLing 阅读(133) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;int main(){ int n,m,i,j,t,a[12010]; long long T,s; scanf("%d",&n); while(n--) { T=0; ... 阅读全文
posted @ 2013-03-04 20:44 YaLing 阅读(828) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;#define N 1000000010#define M 1000010__int64 sum;//long long sum;int a[M],L[M/2+1],R[M/2+1];void merger(int beg,in... 阅读全文
posted @ 2012-12-30 15:24 YaLing 阅读(179) 评论(1) 推荐(0)
摘要: //本题主要运用了树组数组的知识,学了后就会做了#include#includeconst int N=1000010;int n,c[N];//该函数功能是求出n二进制中最右边0的个数的2次幂,也等于c[n]包含的元素个数num[n-lowbit(n)+1]+...+num[n]int lowbi... 阅读全文
posted @ 2012-12-28 22:04 YaLing 阅读(183) 评论(0) 推荐(0)
摘要: #includeint c[1000010];int main(){// freopen("in.txt","r",stdin); int M,N,a,b; scanf("%d%d",&M,&N); c[0]=0; for(int i=1;i<=M;i++) { scanf("%d",&c[i])... 阅读全文
posted @ 2012-12-28 19:06 YaLing 阅读(154) 评论(0) 推荐(0)
上一页 1 ··· 5 6 7 8 9