07 2013 档案
摘要:题目描述二叉排序树的定义是:或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉排序树。 今天我们要判断两序列是否为同一二叉排序树输入开始一个数n,(1 2 #include 3 char a[10000],b[10000]; 4 void creat(char *x,char *y) 5 { 6 x[1]=y[0]; 7 int t=1; 8 for(int i=1;y[i];i++) 9 {10 ...
阅读全文
摘要:题目描述请定一个无向图,顶点编号从0到n-1,用深度优先搜索(DFS),遍历并输出。遍历时,先遍历节点编号小的。输入输入第一行为整数n(0 2 #include 3 int p[101][101];//标记边 4 int o[101];//标记点 5 int num[101];//存遍历完的点 6 int z; 7 //dfs算法 8 void dfs(int k,int v) 9 {10 int j;11 o[v] = 1;12 num[z++] = v;13 for(j = 0;j <= k-1;j ++)14 {15 if(p[...
阅读全文
摘要:题目描述众人皆知,在编程领域中,C++是一门非常重要的语言,不仅仅因为其强大的功能,还因为它是很多其他面向对象语言的祖先和典范。不过这世上几乎没什么东西是完美的,C++也不例外,多继承结构在带来强大功能的同时也给软件设计和维护带来了很多困难。为此,在java语言中,只允许单继承结构,并采用接口来模拟多继承。KK最近获得了一份java编写的迷你游戏的源代码,他对这份代码非常感兴趣。这份java代码是由n个类组成的(本题不考虑接口),现在,他想要知道这份代码中有多少个类没有直接基类。n个类分别用数字1..n表示。输入输入数据包含多组,每组数据格式如下。第一行包含两个整数n,m,表示该份代码中的n个
阅读全文
摘要:题目描述refresh最近发了一笔横财,开了一家停车场。由于土地有限,停车场内停车数量有限,但是要求进停车场的车辆过多。当停车场满时,要进入的车辆会进入便道等待,最先进入便道的车辆会优先进入停车场,而且停车场的结构要求只出去的车辆必须是停车场中最后进去的车辆。现告诉你停车场容量N以及命令数M,以及一些命令(Add num 表示车牌号为num的车辆要进入停车场或便道,Del 表示停车场中出去了一辆车,Out 表示便道最前面的车辆不再等待,放弃进入停车场)。假设便道内的车辆不超过1000000.输入首先输入N和M(0< n,m <200000),接下来输入M条命令。输出输入结束后,如果出现停车场内
阅读全文
摘要:题目描述Well, how do you feel about mobile phone? Your answer would probably be something like that "It's so convenient and benefits people a lot". However, If you ask Merlin this question on the New Year's Eve, he will definitely answer "What a trouble! I have to keep my fingers
阅读全文
摘要:Catch That CowTime Limit:2000MSMemory Limit:65536KTotal Submissions:37622Accepted:11666DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a pointN(0 ≤N≤ 100,000) on a number line and the cow is at a pointK(0 ≤K≤ 100,000) on the
阅读全文
摘要:题目描述给定一个无向连通图,顶点编号从0到n-1,用广度优先搜索(BFS)遍历,输出从某个顶点出发的遍历序列。(同一个结点的同层邻接点,节点编号小的优先遍历)输入输入第一行为整数n(0 2 #include 3 int map[110][110]; 4 int vis[110],que[110]; 5 int m,k,t,flag; 6 void bfs(int t) 7 { 8 int l=0,r=0,tt,j; 9 que[r++]=t;10 while(l<r)11 {12 tt=que[l++];13 if(flag==1...
阅读全文
摘要:http://poj.org/problem?id=2299 1 #include 2 int a[500005]; 3 long long count; 4 5 void merge(int first,int mid,int last) 6 { 7 int s1,s2,f1,f2,i,k,f[500005]; 8 s1=first; 9 s2=mid+1;10 f1=mid;11 f2=last;12 k=0;13 while(s1<=f1&&s2<=f2)14 {15 if(a[s1]<a[s2])16 ...
阅读全文
摘要:Fence RepairTime Limit:2000MSMemory Limit:65536KTotal Submissions:19664Accepted:6237DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needsN(1 ≤N≤ 20,000) planks of wood, each having some integer lengthLi(1 ≤Li≤ 50,000) uni
阅读全文
摘要:DescriptionAccounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc.All what they remember is that MS Inc. posted a surplus or a deficit each month of 1999 and each month when MS Inc. posted surplus, the amount of surplus
阅读全文
摘要:Language:Ubiquitous ReligionsTime Limit:5000MSMemory Limit:65536KTotal Submissions:20242Accepted:9938DescriptionThere are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your uni
阅读全文
摘要:1 #include 2 #include 3 #define N 255 4 int f[N][N]; 5 int main() 6 { 7 int i,j,n; 8 while(~scanf("%d",&n)) 9 {10 memset(f,0,sizeof(f));11 f[0][0]=1;12 f[1][0]=1;13 f[2][0]=3;14 if(n=0;i--)36 printf("%d",f[n][i]);37 printf(...
阅读全文

浙公网安备 33010602011771号