摘要: SkyscraperDescriptionThe Build n' Profit construction company is about to build its tallest building. It will be huge, the tallest building in the world by a wide margin. It will house hundreds of thousands of people and have rocket-powered elevators to the upper floors. They even plan for a shu 阅读全文
posted @ 2011-05-16 23:33 Crazy_yiner 阅读(494) 评论(0) 推荐(0) 编辑
摘要: Median Weight BeadDescriptionThere are N beads which of the same shape and size, but with different weights. N is an odd number and the beads are labeled as 1, 2, ..., N. Your task is to find the bead whose weight is median (the ((N+1)/2)th among all beads). The following comparison has been perfor. 阅读全文
posted @ 2011-05-16 23:32 Crazy_yiner 阅读(434) 评论(0) 推荐(0) 编辑
摘要: Travelling TomTom is a used popsicle salesman. His recent sales at his stand on Gloshaugen haven't been very good, so he's decided that he wants to travel the world selling his merchandise. He has already compiled a list of cities to visit, and have also gathered the costs of the plane trip 阅读全文
posted @ 2011-05-16 23:31 Crazy_yiner 阅读(396) 评论(0) 推荐(1) 编辑
摘要: #include<iostream>#include<stdio.h>#include<cstring>using namespace std;#define INF 5000000int a[201];int c[201][201];int d[201][201];int main(){ int n; int i,j,m,kk,k,p; int max1; scanf("%d",&n); int l; for(l=1;l<=n;l++) { memset(a,0,sizeof(a)); memset(c,0,sizeof( 阅读全文
posted @ 2011-05-16 23:30 Crazy_yiner 阅读(316) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>using namespace std;int main(){ int a[101]; int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=2;i<=n;i++) { int k=a[i]; int j=i-1; while(j>0&&a[j]>k) { a[j+1]=a[j]; j--; } a[j+1]=k; 阅读全文
posted @ 2011-05-16 23:29 Crazy_yiner 阅读(140) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>#include<cstring>using namespace std;int a[101],c[101];int num[100001],f[100001];int main(){int n,m;while(scanf("%d %d",&n,&m)!=EOF){if(n==0&&m==0)break;int sum=0;for(int i=1;i<=n;i++)scanf("%d",&a[i]);fo 阅读全文
posted @ 2011-05-16 23:28 Crazy_yiner 阅读(153) 评论(0) 推荐(0) 编辑
摘要: /**//*用sort排string型的*/bool cmp(string s1,string s2){ if(s1.size()!=s2.size()) //如果长度不等按长度排 长度相等按字典序排 return (s1.size()<s2.size()); else return(s1<s2);//字典序}/**//*用sort排char型的*/bool cmp(char* a,char* b){ return strcmp(a,b)<0? true:false;} struct node{char array[100];}hehe[100];bool cmp(node 阅读全文
posted @ 2011-05-16 23:27 Crazy_yiner 阅读(178) 评论(0) 推荐(0) 编辑
摘要: /**********************************有一定的钱 存在银行里给出可存的钱数 和相应利息第一年的利息会加入到第二年的本金中***********************************/#include<iostream>#include<stdio.h>#include<cstring>using namespace std;int d[50000],v[12],w[12];//数组开大了会超时int main(){ int n; //freopen("out.txt","w", 阅读全文
posted @ 2011-05-16 23:27 Crazy_yiner 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 1。qsort, 即快速排序, 包含在<cstdlib>或<stdlib.h>中,函数有四个参数, 没有返回值 下面是一个典型的写法:qsort(s,n,sizeof(s[0]),cmp);其中, s是需要排序的数组名, 也可以理解成开始地址, 因为你如果只需要对数组的部分排序的话, s可以写成&s[i]的形式的第二个参数n是参与排序的元素个数, 第三个参数是单个元素的大小,通常我们用sizeof()来获取大小, 因为它足够放心 绝对无毒^_^而且 很多时候我们需要对结构体进行排序的 你很难把握它的大小的~最后一个参数, 也就是我今天对着愣了很久的东东了 什么鸟 阅读全文
posted @ 2011-05-16 23:26 Crazy_yiner 阅读(774) 评论(0) 推荐(0) 编辑
摘要: 这题把前面两道题组合到了一起 判断最小生成树 和是否是一棵树#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int father[101];bool flags[101];struct country{ int first; int second; int value;}a[5001];bool cmp(country x,country y){ return x.value<y.value;}int ma 阅读全文
posted @ 2011-05-16 23:19 Crazy_yiner 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 为了学习最小生成树 这两天学习了并查集 做并查集的题碰到了一道最小生成树 自己搞定了这道题 非常的高兴哈~#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int father[101];void makeset(int n){ for(int i=1;i<=n;i++) { father[i]=i; }}int findset(int x){ if(father[x]!=x) { father[x]=findset(father[x]); } retur 阅读全文
posted @ 2011-05-16 23:18 Crazy_yiner 阅读(251) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>#include<string.h>using namespace std;bool flags[1001];int father[1001];void makeset(int n){ for(int i=1;i<=n;i++) { father[i]=i; }}int findset(int x){ if(x!=father[x]) { father[x]=findset(father[x]); } return father[x];}void Union(int a,int b) 阅读全文
posted @ 2011-05-16 23:17 Crazy_yiner 阅读(189) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>using namespace std;int father[10000001],num[10000001];/**//*初始化数组*/void makeset(int x){ for(int i=0;i<=x;i++) { father[i]=i; num[i]=1; }}int findset(int x)//查{ if(x!=father[x]) { father[x]=findset(father[x]); }//回溯 return father[x];}void Union(int a 阅读全文
posted @ 2011-05-16 23:16 Crazy_yiner 阅读(207) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>using namespace std;int sum,n,m;int father[50001];void makeset(int x){ for(int i=1;i<=x;i++) { father[i]=i; }}int findset(int x)//查{ if(x!=father[x]) { father[x]=findset(father[x]); }//回溯 return father[x];}void Union(int a,int b){ int x=findset(a); i 阅读全文
posted @ 2011-05-16 23:15 Crazy_yiner 阅读(164) 评论(0) 推荐(0) 编辑
摘要: /*如果两个学生的信仰一样 则总的宗教个数减一 */#include<iostream>#include<stdio.h>using namespace std;int sum,n,m;int father[50001];void makeset(int x){ for(int i=1;i<=x;i++) { father[i]=i; }}int findset(int x)//查{ if(x!=father[x]) { father[x]=findset(father[x]); }//回溯 return father[x];}void Union(int a,i 阅读全文
posted @ 2011-05-16 23:05 Crazy_yiner 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 学习并查集做的第一道题 基本上就是套用模版的#include<iostream>#include<stdio.h>using namespace std;int n,m;int father[30001],num[30001];/**//*初始化数组*/void makeset(int x){ for(int i=0;i<x;i++) { father[i]=i; num[i]=1; }}int findset(int x)//查{ if(x!=father[x]) { father[x]=findset(father[x]); }//回溯 return fath 阅读全文
posted @ 2011-05-16 23:03 Crazy_yiner 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 寒假的时候就看到并查集了 当时觉得有点难 另外没怎么听说过这个就没学 这几天想学最小生成树 发现最小生成树等许多东西可以靠并查集来实现 所以今天学习了一下并查集 用我看新算法的老方法 一遍一遍的看 最后终于有了点头绪 跟着教程写了一道题之后 下午自己又独立的做了几道题 感觉还是不错的 当然,有些题没有过 大体的思路我了解 但是可能在一些细节的地方没有处理好 导致wrong 有时间还有继续改下面是我认为比较合适的并查集模板~#include<iostream>#include<stdio.h>using namespace std;int father[10000001] 阅读全文
posted @ 2011-05-16 23:01 Crazy_yiner 阅读(211) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>const int MIN = -999999999;//定义MIN为只读变量 为一个非常小的值int a[100001];int ans[100001];using namespace std;int main(){ int n; int an; while(scanf("%d",&n)!=EOF) { if(n==0) break; int sum=0; int k=MIN; for(int i=1;i<=n;i++) { scanf("%d" 阅读全文
posted @ 2011-05-16 22:58 Crazy_yiner 阅读(214) 评论(0) 推荐(0) 编辑
摘要: An escapeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)otal Submission(s): 227 Accepted Submission(s): 56Problem DescriptionYou are now in a maze. You mark all theblocks you've visited by '@',sowhen you see a wall '#' or a visited block '@ 阅读全文
posted @ 2011-05-16 22:53 Crazy_yiner 阅读(181) 评论(0) 推荐(0) 编辑
摘要: L2B的演唱会Description著名乐队L2B宣布要在Music岛举办一场演唱会,售票当天那家伙,那场面,相当热闹,真是锣鼓喧天,鞭炮齐鸣,旌旗招展,人山人海啊。L2B的粉丝小C得知消息,飞奔到售票处,却发现买票的人已经排起了长龙的队伍,正当他万般绝望的时候,他看到了敬爱的PengSir,于是他向PengSir请求帮助。PengSir嘴角微微一笑,说道:票我倒是可以给你一张,可是白给的话就太没意思了,这样吧,我有一个问题考考你,如果你能在5秒钟内答出来的话,我就送你这张票,怎么样?小C急不可待的说:没问题。于是PengSir徐徐说道:这里排队的一共有N个人,每个人之前都发了一个号码牌(数字 阅读全文
posted @ 2011-05-16 22:39 Crazy_yiner 阅读(202) 评论(0) 推荐(0) 编辑