上一页 1 ··· 7 8 9 10 11 12 13 下一页
摘要: 相同的雪花时间限制:1000 ms | 内存限制:65535 KB难度:4描述You may have heard that no two snowflakes are alike. Your task is to write a program to determine whether this is really true. Your program will read information about a collection of snowflakes, and search for a pair that may be identical. Each snowflake has s 阅读全文
posted @ 2011-10-25 19:14 qijinbiao1 阅读(478) 评论(0) 推荐(0) 编辑
摘要: 判断输入的是不是一棵树输入The input will consist of a sequence of descriptions (test cases) followed by a pair of negative integers. Each test case will consist of a sequence of edge descriptions followed by a pair of zeroes Each edge description will consist of a pair of integers; the first integer identifies t 阅读全文
posted @ 2011-10-17 15:33 qijinbiao1 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 士兵杀敌(四)时间限制:2000 ms | 内存限制:65535 KB难度:5描述南将军麾下有百万精兵,现已知共有M个士兵,编号为1~M,每次有任务的时候,总会有一批编号连在一起人请战(编号相近的人经常在一块,相互之间比较熟悉),最终他们获得的军功,也将会平分到每个人身上,这样,有时候,计算他们中的哪一个人到底有多少军功就是一个比较困难的事情,军师小工的任务就是在南将军询问他某个人的军功的时候,快速的报出此人的军功,请你编写一个程序来帮助小工吧。假设起始时所有人的军功都是0.输入只有一组测试数据。每一行是两个整数T和M表示共有T条指令,M个士兵。(1<=T,M<=1000000)随 阅读全文
posted @ 2011-10-15 21:02 qijinbiao1 阅读(295) 评论(0) 推荐(1) 编辑
摘要: 士兵杀敌(三)时间限制:2000 ms | 内存限制:65535 KB难度:5描述南将军统率着N个士兵,士兵分别编号为1~N,南将军经常爱拿某一段编号内杀敌数最高的人与杀敌数最低的人进行比较,计算出两个人的杀敌数差值,用这种方法一方面能鼓舞杀敌数高的人,另一方面也算是批评杀敌数低的人,起到了很好的效果。所以,南将军经常问军师小工第i号士兵到第j号士兵中,杀敌数最高的人与杀敌数最低的人之间军功差值是多少。现在,请你写一个程序,帮小工回答南将军每次的询问吧。注意,南将军可能询问很多次。输入只有一组测试数据第一行是两个整数N,Q,其中N表示士兵的总数。Q表示南将军询问的次数。(1<N<= 阅读全文
posted @ 2011-10-15 20:20 qijinbiao1 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 求逆序数 时间限制:2000 ms | 内存限制:65535 KB 难度:5描述在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数。现在,给你一个N个元素的序列,请你判断出它的逆序数是多少。比如 1 3 2 的逆序数就是1。输入第一行输入一个整数T表示测试数据的组数(1<=T<=5)每组测试数据的每一行是一个整数N表示数列中共有N个元素(2〈=N〈=1000000)随后的一行... 阅读全文
posted @ 2011-10-15 14:28 qijinbiao1 阅读(1844) 评论(0) 推荐(1) 编辑
摘要: /*hdu1754满二叉树递推式处理线段树,输入输出优化外挂*/#include<cstdio>const int M=262144;int max(int a,int b){return a>b?a:b;}int tr[16],n,m,i,a,b,c,N;inline bool scan_ud(int &num) //输入函数,以字符的形式输入{ char in; in = getchar(); if(in == EOF) return false; while(in < '0' || in > '9') in = get 阅读全文
posted @ 2011-09-21 20:40 qijinbiao1 阅读(265) 评论(0) 推荐(0) 编辑
摘要: #include "iostream"#include <cstdio>#define MAX 200005#define lc(x) ((x)<<1)#define rc(x) (((x)<<1)+1)using namespace std;struct node {int l,r,m;};int score[MAX];node tree[MAX*3];int N,M,p,q;char cmd[2];int mmax(int x,int y){return x>y? x:y;}int build(int l,int r,int i 阅读全文
posted @ 2011-09-21 15:51 qijinbiao1 阅读(177) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<cstdio>#include<cstring>using namespace std;const int MAX=100000;int svalue;struct node{int left,right,cover;};node tree[MAX*3];bool used[31];void built(int L,int R,int id)//建树{tree[id].cover=1;//初始化tree[id].left=L;tree[id].right=R;if(L<R){int mid=(L+R 阅读全文
posted @ 2011-09-20 20:09 qijinbiao1 阅读(190) 评论(0) 推荐(0) 编辑
摘要: #include "iostream"#include "string"#define Max 50005using namespace std;int N,sum;struct node_tree{int left;int right;int num;};node_tree node[Max*3];void build(int i,int l,int r)//建树{node[i].left=l;node[i].right=r;node[i].num=0;if (l<r){int mid=(l+r)>>1;build(2*i,l,mid 阅读全文
posted @ 2011-09-20 19:38 qijinbiao1 阅读(154) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;bool map[4][4];bool record[4][4];//自动初始化为0;int num;void init(){int i,j;char ch;for (i=0;i<4;i++){for (j=0;j<4;j++){cin>>ch;if (ch=='+'){map[i][j]=false;}else map[i][j]=true;}}//getchar();}bool jianc(){int i,j;num=0;for (i=0;i<4;i++) 阅读全文
posted @ 2011-09-19 20:26 qijinbiao1 阅读(188) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 下一页