上一页 1 ··· 6 7 8 9 10 11 12 13 下一页

2012年8月13日

nyoj123 士兵杀敌(四)

摘要: 1 #include<stdio.h> 2 #define N 1000010 3 struct node{ 4 int l,r; 5 int inc; 6 }tree[3*N]; 7 inline void build(int l,int r,int i) 8 { 9 tree[i].l=l;10 tree[i].r=r;11 if(l<r){12 int mid=(l+r)>>1;13 build(l,mid,i<<1);14 build(mid+1,r,(i<<1)+1);15 }16 }1... 阅读全文

posted @ 2012-08-13 09:37 小花熊 阅读(348) 评论(0) 推荐(0) 编辑

2012年8月10日

poj3468 A Simple Problem with Integers

摘要: 1 #include<stdio.h> 2 #define N 100010 3 struct node{ 4 int l,r; 5 __int64 inc,sum;//注意要定义为__int64型 6 }tree[3*N]; 7 int num[N]; 8 void build(int l,int r,int i)//建立线段树 9 {10 tree[i].l=l;11 tree[i].r=r;12 tree[i].inc=0;13 if(l==r){14 tree[i].sum=num[l];//叶子节点赋值 15 ... 阅读全文

posted @ 2012-08-10 20:41 小花熊 阅读(148) 评论(0) 推荐(0) 编辑

poj2182 Lost Cows

摘要: 1 #include<stdio.h> 2 #define N 8010 3 struct node{ 4 int l,r; 5 int len;//len用来存放某一段数据的个数 6 }tree[N<<1]; 7 int s[N],result[N]; 8 void build(int l,int r,int i) 9 {10 tree[i].l=l;11 tree[i].r=r;12 tree[i].len=r-l+1; 13 if(l==r) return;14 int mid=(l+r)>>1;15 build(l,m... 阅读全文

posted @ 2012-08-10 15:04 小花熊 阅读(333) 评论(0) 推荐(0) 编辑

hdu1754 I Hate It

摘要: 1 #include<cstdio> 2 #include<cmath> 3 #include<iostream> 4 #define MAX 200010 5 using namespace std; 6 struct node{ 7 int l,r; 8 int max; 9 }tree[3*MAX];//三倍就差不多了10 int s[MAX];11 void build(int l,int r,int i)//负责建树 12 {13 tree[i].l=l;14 tree[i].r=r;15 if(l==r){16 tree[i... 阅读全文

posted @ 2012-08-10 11:00 小花熊 阅读(157) 评论(0) 推荐(0) 编辑

2012年8月9日

hdu1251统计难题

摘要: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 using namespace std; 5 struct node{ 6 int count; 7 node *next[26]; 8 node(){ //初始化数据 9 memset(next,NULL,sizeof(next));10 count=0;11 }12 };13 node *p,*root=new node();14 void insert(char *s)//插入新单词 15 {1... 阅读全文

posted @ 2012-08-09 17:27 小花熊 阅读(266) 评论(0) 推荐(0) 编辑

zoj1610 Count the Colors

摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #define N 8001 4 int color[N],cnt[N];//这个cnt是用来记录颜色i出现的段数 ,注意cnt里的这个N真的需要好大,我以为就几百种呢,结果WA好多次 5 int main() 6 { 7 int i,j,a,b,c,max,n; 8 while(~scanf("%d",&n)){ 9 for(max=i=0;i<n;++i){10 scanf("%d%d%d",&a,&b,& 阅读全文

posted @ 2012-08-09 17:22 小花熊 阅读(571) 评论(0) 推荐(0) 编辑

nyoj144 小珂的苦恼

摘要: #include<stdio.h>inline int gcd(int a,int b){ return b?gcd(b,a%b):a;}int main(){ int T,a,b,k,n; scanf("%d",&T); while(T--) { scanf("%d%d%d",&a,&b,&n); k=gcd(a,b); if(n%k) puts("No"); else puts("Yes"); } return 0;}本题主要用到的是扩展欧几里德定理: 对于与不完全为 阅读全文

posted @ 2012-08-09 12:01 小花熊 阅读(222) 评论(1) 推荐(1) 编辑

nyoj163 Phone List

摘要: 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 using namespace std; 5 struct node{ 6 node *next[10]; 7 int end; 8 node(){ //构造函数,方便初始化数据 9 memset(next,NULL,sizeof(next));10 end=0; //end=0表示一般节点,end=1标志一个电话号的结束 11 }12 };13 node *root;14 bool insert(... 阅读全文

posted @ 2012-08-09 01:45 小花熊 阅读(245) 评论(0) 推荐(0) 编辑

2012年8月8日

nyoj290 动物统计加强版

摘要: 1 #include<cstring> 2 #include<cstdio> 3 #include<iostream> 4 using namespace std; 5 struct node{ 6 node *next[26]; 7 int count; 8 node(){ //构造函数,初始化数据 9 memset(next,0,sizeof(next));10 count=0;11 }12 };13 int maxi; //用来存放最大出现次数 14 char maxs[11];//存放出现次数最多的字符串... 阅读全文

posted @ 2012-08-08 21:10 小花熊 阅读(238) 评论(0) 推荐(0) 编辑

nyoj93 汉诺塔(三)

摘要: 1 #include<stack> 2 #include<iostream> 3 using namespace std; 4 int main() 5 { 6 int i,t,N,a,b,m,n; 7 stack<int> s[4]; //定义一个数组栈 8 cin>>N; 9 while(N--)10 {11 cin>>m>>n;12 for(i=1;i<4;i++)13 while(!s[i].empty()) s[i].pop(); //清空栈 14 for(i=m;i... 阅读全文

posted @ 2012-08-08 17:01 小花熊 阅读(214) 评论(0) 推荐(0) 编辑

上一页 1 ··· 6 7 8 9 10 11 12 13 下一页

导航