上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 57 下一页

2011年7月17日

poj 1068 Parencodings

摘要: #include<iostream>#include<memory.h>using namespace std;int list[44],paren[44],stack_paren[22]; void f(int n){ int i,j,w,top; memset(paren,-1,sizeof(paren)); //paren数组中-1表示(, 1表示) list[0]=0;top=0;w=0; for(i=1;i<=n;i++) { cin>>list[i]; w+=list[i]-list[i-1]+1; paren[w]=1; stack_pa 阅读全文

posted @ 2011-07-17 23:45 sysu_mjc 阅读(87) 评论(0) 推荐(0) 编辑

poj 1065 Wooden Sticks

摘要: #include <iostream>using namespace std;struct wood { int w; int l;}Wood[5000];int cmp(const void *a,const void *b){ if((*(wood*)a).l==(*(wood*)b).l) //不能写成(wood*)a->l,要写成(*(wood*)a).l return (*(wood*)a).w-(*(wood*)b).w; return (*(wood*)a).l-(*(wood*)b).l;}//按木棍的长度从小到大排序,当木棍长度相等时,按重量小到大排序。这样 阅读全文

posted @ 2011-07-17 23:43 sysu_mjc 阅读(121) 评论(0) 推荐(0) 编辑

poj 1061 青蛙的约会

摘要: // 题意: 解同余方程 (m-n)t≡y-x(mod L),求出t的最小解#include<iostream>using namespace std;int x_0,y_0,q; void extend_eulid(int a,int b) //x_0*a+y_0*b=gcd(a,b)=q{ if(b==0) { x_0=1;y_0=0;q=a; } else { extend_eulid(b,a%b); int temp=x_0; x_0=y_0;y_0=tem... 阅读全文

posted @ 2011-07-17 23:41 sysu_mjc 阅读(116) 评论(0) 推荐(0) 编辑

poj 1051 P,MTHBGWB

摘要: #include<iostream>#include<map>#include<string>using namespace std;map<char,string>col;map<char,string>::iterator ite;void f(string str){ string ss,temp; int i,top=0,len_pre=0,len[101]; for(i=0;i<str.size();i++) { ite=col.find(str[i]); ss.append(ite->second); len[ 阅读全文

posted @ 2011-07-17 23:40 sysu_mjc 阅读(184) 评论(0) 推荐(0) 编辑

poj 1042 Gone Fishing

摘要: #include<iostream>using namespace std;const int iMax = 30;const int jMax = 200;/*首先是贪心的思路:枚举所经过的湖的个数k,每种情况减去所需步行的时间,剩下的就是钓鱼的时间了,之后就只需要在所剩的时间内使钓鱼数最大,因此每次选择最多鱼的湖点,最后构造起时间段。*//*解此题的主要方法是枚举+贪心。刚开始的时候还没想到一个好方法,因为当前鱼最多的池塘是变化的,而题目所给描述里面的钓鱼又是有顺序的,即:John starts at lake 1, but he can finish at any lake 阅读全文

posted @ 2011-07-17 23:38 sysu_mjc 阅读(167) 评论(0) 推荐(0) 编辑

poj 1050 To the Max

摘要: #include<iostream>using namespace std;int rec[101][101];int sub(int ii,int jj,int len,int wid){ int sum=0; for(int i=ii;i<=len;i++) for(int j=jj;j<=wid;j++) sum+=rec[i][j]; return sum;}int main(){ int i,j,n,max=-200,ll,ww,s; cin>>n; for (i=1;i<=n;i++) for(j=1;j<=n;j++) { scan 阅读全文

posted @ 2011-07-17 23:38 sysu_mjc 阅读(88) 评论(0) 推荐(0) 编辑

poj 1019 Number Sequence

摘要: // 题意: 一串有规律的数字,// 11212312341234512345612345671234567812345678912345678910123456789101112345678910...// 拆分出来就是 11 212 3123 41234 5… 问第i位数字是多少,i ≤ 2147483647#include <iostream>#include <string.h>using namespace std;int count[35000];int digit(int n) //返回n的位数{ int d = 0; while(n) { ... 阅读全文

posted @ 2011-07-17 23:36 sysu_mjc 阅读(138) 评论(0) 推荐(0) 编辑

poj 1006 Biorhythms

摘要: //题意:比如输入5,20,34,求一个数 M 满足// M = 5 + 23 * P1 = 20 + 28 * P2 = 34 + 33 * P3; (P1,P2,P3,都为整数)//即是 M≡5(mod 23)≡20(mod 28)≡34(mod 33) ,其中 23 , 28, 33 两两互素, 求线性同余方程组,解得M=19900#include<iostream> //线性同余方程组 using namespace std;int x,y,q;void extend_eluid(int a,int b) //扩展欧几里德算法{ if(b=... 阅读全文

posted @ 2011-07-17 23:33 sysu_mjc 阅读(161) 评论(0) 推荐(0) 编辑

poj 1005 I Think I Need a Houseboat

摘要: #include <iostream>#define pi 3.1415926535898using namespace std;int main(){ double x,y; int n; cin>>n; for(int i=1;i<=n;i++) { cin>>x>>y; cout<<"Property "<<i<<": This property will begin eroding in year "<<(int)(0.5*pi*(x*x+y*y 阅读全文

posted @ 2011-07-17 23:32 sysu_mjc 阅读(88) 评论(0) 推荐(0) 编辑

poj 1003 Hangover

摘要: #include <iostream>using namespace std;double list[500];void creat(){ list[0]=0.0; for(int i=1;;i++) { list[i]=list[i-1]+1.0/(i+1); if(list[i]>=5.20) break; }}int main(){ double n; int i; creat(); while(cin>>n&&n) { for(i=1;;i++) if(list[i]>=n) break; cout<<i<<& 阅读全文

posted @ 2011-07-17 23:31 sysu_mjc 阅读(101) 评论(0) 推荐(0) 编辑

上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 57 下一页

导航