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

2011年7月18日

poj 2142 The Balance

摘要: #include <iostream>using namespace std;int x0,y0,g;void extend_gcd(int a,int b){ if(b==0) { x0=1;y0=0;g=a; } else { extend_gcd(b,a%b); int tmp=x0; x0=y0; y0=tmp-(a/b)*y0; }}int main(){ int a,b,d,x,y;bool tag; while(cin>>a>>b>>d&&a) { int res1,res2;tag=1; if(a<b) { 阅读全文

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

poj 2182 Lost Cows

摘要: /* 题意: 有n个数,从1到n,打乱顺序, 现输入n-1个数,第i个数表示序列中第1到i-1的数比第i个数小的个数.要求输出该序列 输入: 5 1 2 1 0 输出: 2 4 5 3 1*/#include <iostream> //线段树using namespace std;struct node{ int l,r,num; //num记录[l,r]中还剩余多少人尚未被确定}tree[40000];void build(int n,int s,int t){ tree[n].l=s; tre... 阅读全文

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

poj 1799 Yeehaa!

摘要: #include <iostream>#include <math.h>const double pi=3.1415926535898;using namespace std;int main(){ int t,i;double R,n; cin>>t; for(i=1;i<=t;i++) { cin>>R>>n; printf("Scenario #%d:\n",i); printf("%.3lf\n\n",R*sin(pi/n)/(1+sin(pi/n))); } return 0;} 阅读全文

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

poj 2115 C Looooops

摘要: // 题意: 解同余方程 Cx≡B-A ( mod 2^k ) ,求出x的最小解#include<iostream>#include <math.h>using namespace std;long long x_0,y_0,q; void extend_eulid(long long a,long long 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); ... 阅读全文

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

poj 1363 Rails

摘要: #include<iostream> #include<stack> using namespace std; int n,target[1001],temp; int main() { while(cin >> n&&n) { while(cin >> temp&&temp) { stack<int> s; int A = 1,B = 1; //A是有顺序的车厢号,B是栈堆指针 target[1] = temp; for(int i = 2;i <= n;++i) { cin >> 阅读全文

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

poj 1330 Nearest Common Ancestors

摘要: #include<iostream>#include<memory.h>using namespace std;int node[10001];int path1[10001],path2[10001];void parent(int list[],int s,int& top){ top=-1; do { list[++top]=s; s=node[s]; } while (s);}int main(){ int t,n,i,j,p,c; cin>>t; while(t--) { cin>>n; memset(node,0,sizeof 阅读全文

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

2011年7月17日

poj 1321 棋盘问题

摘要: #include<iostream>using namespace std;int board[10][10];int n,k,c;void dfs(int num)//深度搜索。棋盘上的一个点共有三种状态:未放棋子的棋盘点,放了棋子的棋盘点,空白点。分别用:等于0,大于0,小于0{ if(num>k) { c++; return; } for(int u=num-1;u<n;u++) { if(k-num>n-1-u) return; for(int i=0;i<n;i++) { //同一行不允许存在两个棋子 if(board[u][i]>0) br 阅读全文

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

poj 1323 Game Prediction

摘要: #include<iostream>#include<algorithm>#include<list>using namespace std;bool cmp(const int a,const int b){ return a>b;}int main(){ int n,m,i,count,ff=0;int cards[51]; while (cin>>m>>n&&n&&m) { for(i=1;i<=n;i++) cin>>cards[i]; sort(cards+1,card 阅读全文

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

poj 1298 The Hardest Problem Ever

摘要: #include<iostream>#include<string>using namespace std;int main(){ string start,str,end; while(cin>>start&&start!="ENDOFINPUT") { scanf("\n"); getline(cin,str); for(int i=0;i<str.size();i++) { if(str[i]>='A'&&str[i]<='E') 阅读全文

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

poj 1258 Agri-Net

摘要: #include<iostream> //最小生成树prim算法using namespace std;const int MAXN=105; //最大顶点数int n,edge[MAXN][MAXN]; //n记录顶点数struct MST //最小生成树的边{ int s,t,w;}mst[MAXN];void Prim(){ int sum=0,i,j,k; //sum记录最小生成树的路径和 for(i=0;i<n-1;i++) //顶点下标从0开始,默认选择顶点0加入生成树 { mst[i... 阅读全文

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

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

导航