上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 57 下一页

2011年7月18日

poj 1552 Doubles

摘要: #include <iostream>#include <algorithm>using namespace std;int top,list[16];bool db(int i){ int j; for( j=i+1;j<top;j++) if(list[j]>=2*list[i]) break; if(list[j]==2*list[i]) return true; return false;}int main(){ int a,s,i; while(cin>>a&&a!=-1) { list[0]=a;top=1; whil 阅读全文

posted @ 2011-07-18 11:23 sysu_mjc 阅读(154) 评论(0) 推荐(0) 编辑

poj 1470 Closest Common Ancestors

摘要: #include <iostream> //并查集using namespace std;int main(){ int n,i,j; int parent[910],closest[910],vis_anc[910]; while(scanf("%d",&n)!=EOF) { int num,father,child; memset(parent,0,sizeof(parent[0])*(n+1)); for(i=1;i<=n;i++) { scanf("%d:(%d)",&father,&num); whil 阅读全文

posted @ 2011-07-18 11:22 sysu_mjc 阅读(154) 评论(0) 推荐(0) 编辑

poj 1328 Radar Installation

摘要: #include <iostream>#include <math.h>#include<algorithm>using namespace std;struct seg { double left;double right; bool operator<(const seg& a)const { return left<a.left; }}range[1001];int main(){ int n,d,i,t=1;double x,y;bool tag; while(cin>>n>>d) { if(n==0&am 阅读全文

posted @ 2011-07-18 11:18 sysu_mjc 阅读(158) 评论(0) 推荐(0) 编辑

poj 1032 Parliament

摘要: #include <iostream>using namespace std;int main(){ int s,list[1000],i,p=0,top=0; scanf("%d",&s); for(i=2;;i++) { if(p+i<=s) { p+=i; list[top++]=i; } else break; } p=s-p; int a=p/top,b=p%top; for(i=0;i<top;i++) list[i]+=a; for(i=top-1;i>top-1-b;i--) list[i]++; for(i=0;i&l 阅读全文

posted @ 2011-07-18 11:17 sysu_mjc 阅读(118) 评论(0) 推荐(0) 编辑

poj 1011 Sticks

摘要: #include <iostream>using namespace std;int sticks[200],visited[200];int flag,total;int t,seg,num;int cmp(const void* a,const void* b){ return (*(const int*)b)-(*(const int *)a);}void solve(int k,int sum,int cnt) //sum 是正在拼的木棍已经拼出的长度, k是从哪根碎木块开始拼,cnt是正在拼第几根木块{ if(num==cnt) flag=true; else if(su 阅读全文

posted @ 2011-07-18 11:16 sysu_mjc 阅读(164) 评论(0) 推荐(0) 编辑

poj 1007 DNA Sorting

摘要: #include <iostream>#include <algorithm>using namespace std;struct node{ char ch[52]; int unsort; bool operator<(const node& nd)const { return unsort<nd.unsort; }}dna[110];int us(char c[],int n){ int sum=0; for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) if(c[i]>c[j]) sum 阅读全文

posted @ 2011-07-18 11:15 sysu_mjc 阅读(105) 评论(0) 推荐(0) 编辑

poj 3748 位操作

摘要: #include<iostream> //位运算using namespace std;int main(){ int r,x,y; scanf("%x,%d,%d",&r,&x,&y); r=r&(~(1<<x)); r=r|(1<<y); r=r|(1<<(y-1)); r=r&(~(1<<(y-2))); printf("%x\n",r); return 0;} 阅读全文

posted @ 2011-07-18 00:11 sysu_mjc 阅读(120) 评论(0) 推荐(0) 编辑

poj 3468 A Simple Problem with Integers

摘要: // 题意: 序列A[1-N], (1) C a b c 表示区间[a,b]里的数都加上c, (2) Q a b 查询区间[a,b]各个数的和#include <iostream> // 线段树, 修改和查询区间using namespace std;struct segment{ int l,r; __int64 sum,off; // sum记录该区间的和, 当覆盖范围为整个区间时,off记录所有的偏移量c, off初始化默认为0}tree[400000];int arr[100005],c;void built_tree(int n, int s,int... 阅读全文

posted @ 2011-07-18 00:10 sysu_mjc 阅读(146) 评论(0) 推荐(0) 编辑

poj 2606 Rabbit hunt

摘要: #include<iostream> //参照poj 1118 Lining Upusing namespace std;double c[201][2];//坐标数组double k[201];//斜率数组//QSORT的double类型比较函数int cmp_double( const void* a , const void* b ) { return *(double *)a > *(double *)b ? 1 : -1; } int main(){ int n,cnt,max,num; cin>>n; for(int i = 1;i <= n; 阅读全文

posted @ 2011-07-18 00:09 sysu_mjc 阅读(135) 评论(0) 推荐(0) 编辑

poj 3264 Balanced Lineup

摘要: // 题意: 给出一组数,输出区间最大值与最小值的差值#include <iostream> // 线段树,求区间最值问题using namespace std;struct segment{ int high,low; //记录该区间的最大值和最小值}table[200000];int arr[50005],MAX,MIN;void built_tree(int n,int s,int t) //建树,其中第n个区间的范围是[s,t]{ if(s==t) table[n].high=table[n].low=arr[s]; e... 阅读全文

posted @ 2011-07-18 00:09 sysu_mjc 阅读(130) 评论(0) 推荐(0) 编辑

上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 57 下一页

导航