摘要:
Problem D Time Limit : 2000/1000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)Total Submission(s) : 11 Accepted Submission(s) : 4Problem Description Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capita... 阅读全文
摘要:
Online Judge Problem Set Authors Online Contests User Web BoardHome PageF.A.QsStatistical Charts ProblemsSubmit ProblemOnline StatusProb.ID: RegisterU... 阅读全文
摘要:
Red and BlackTime Limit: 1000MS Memory Limit: 30000K Total Submissions: 17584 Accepted: 9279 DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But h.. 阅读全文
摘要:
/*猜想对于任意大于1的自然数n,若n为奇数,则将n变为3n+1,否则将n变为一半,求变换的次数 其中n<10^9开始不用长整形的时候会溢出,但是还可以用double解决这个问题刘汝佳教我的*//*//法1 长整形法#include<iostream>#include<math.h>using namespace std;int main(){ __int64 n,count = 0; while(scanf("%I64d",&n)!=EOF) { while(n>1) { if(n%2==1) ... 阅读全文
摘要:
#include<iostream>#include<stdio.h>#include<malloc.h>using namespace std;#define MaxSize 100#define MaxWidth 40typedef char ElemType;typedef struct Node2{ char data;//数据域 struct Node2*lchild,*rchild;//左指针域,右指针域}BTNode;void CreateBTNode(BTNode *&b,char *str)//由str串创建二叉链{ BTNode 阅读全文
摘要:
/*最长回文子串*/#include<iostream>#include<string.h>#include<ctype.h>using namespace std;#define Max 5000 +10char buf[Max],s[Max];int p[Max];int main(){ int n,m=0,max=0; int i,j; //int k; int x,y; fgets(buf,sizeof(s),stdin); n=strlen(buf); for(i=0;i<n;i++) if(isalpha(buf[i])) ... 阅读全文
摘要:
#include<iostream>using namespace std;#define maxvex 100typedef struct{ int a[maxvex][maxvex]; int vex;}Graph;int visiteded[maxvex];void DFS(Graph G,int v){ printf("v%d ",v+1); visiteded[v]=1; for(int j=0;j<G.vex;j++) if(G.a[v][j]==1&&visiteded[j]==0) DFS(G,j);}void ... 阅读全文
摘要:
/*不用数组也行,scanf返回成功输入变量的个数,按回车+ctrl+z+回车*/#include<iostream>using namespace std;int main(){ int x,n=0,min,max,s=0; scanf("%d",&x); s=min=max=x; n=1; while(scanf("%d",&x)==1) { s+=x; if(x<min)min=x; if(x>max)max=x; n++; } printf("%d %d %.3lf\n",min,m.. 阅读全文
摘要:
/*交换两个数不用中间变量*/#include<iostream>using namespace std;int main(){ int a,b; scanf("%d%d",&a,&b); a=a+b; b=a-b; a=a-b; printf("%d %d\n",a,b); return 0;} 阅读全文
摘要:
Leftmost DigitTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8784 Accepted Submission(s): 3391Problem DescriptionGiven a positive integer N, you should output the leftmost digit of N^N. InputThe input contains several test cases. The first ... 阅读全文