- 博客(86)
- 问答 (5)
- 收藏
- 关注
原创 839 - Not so Mobile
描述:这是物理上的一个杠杆问题,就是重物与力矩相乘,看一下两边是否相等,才开始我没有采用建树方法,后来又用建树的方法做了一下,不过很惭愧,建树时出现了问题,结果好几次wa……代码一:不建树代码#include #include #include using namespace std;int flag;int creat_recursion(int w1,int d1
2012-09-30 17:11:27 739
原创 327 Evaluating Simple C Expressions
描述:题目很简单,刚开始考虑问题时忽略了所有的字母所代表的值需要全部变化后才进行运算,结果交了几次错误代码,悲催啊……#include #include #include using namespace std;int main(){ //freopen("a.txt","r",stdin); int n,i,j; int s_fl
2012-09-26 14:33:47 876
原创 699 - The Falling Leaves
描述:这道题内容是通过构造一个二叉树,看一下那些叶子在树上时垂直位置是重合的,重合的就加在一块求和,然后水平输出就可以了,关键是在dfs中的优先遍历统计叶子在垂直位置的数目和,然后就可以AC了#include #include #include using namespace std;struct Tnode{ int c; Tnode *lef
2012-09-24 12:54:53 491
原创 712 - S-Trees
其实就是刘汝佳书上的一道题改了一点而已,类似于模拟题,就是看题麻烦点,其实意思很简单的,一遍AC#include #include #include using namespace std;int main(){ //freopen("a.txt","r",stdin); int n,i(1); char str[1000010];
2012-09-17 22:19:04 639
原创 297 - Quadtrees
描述:这道题就是求像素相加问题,给出了两个四叉树的先序输出,构建完这两个四叉树再合并,然后计算像素结果就ok了,注意,像素开始值是1024,也就是说输出如果大于1024就程序错了,关键是能够合并两个四叉树#include #include #include using namespace std;struct Tnode{ char v; str
2012-09-13 17:48:06 444
原创 548 - Tree
一道根据中序和后序输出建树再计算出每条路径的节点数和求路径值最小且最后的叶子节点值最小的题,步骤就是建树,求路径值,路径值相同的要选取最后末端的叶子结点值最小的哪一个,然后就是输出啦#include #include #include using namespace std;struct Tnode{ int v; struct Tnode
2012-09-12 10:21:53 419
原创 112 - Tree Summing
交啦好几次运行错误,原来是数组开小了,快哭死了,本体没别的难点,就是建一个简单的二叉树,然后用递归取值就行了,如果学的比较好的话可以不建树就能做 #include #include #include #include using namespace std;int N,flag; struct p{ int pri; p *left,*right;} ;p
2012-09-11 09:06:04 448
原创 10050 - Hartals
纯模拟问题……水题#include #include #include #include using namespace std;int main(){ //freopen("a.txt","r",stdin); int T,N,P,i,j,count,flag; int s[1010],str[1010],num[4010]; scanf("%d"
2012-09-11 09:04:55 415
原创 540 - Team Queue
题目的意思就是排队买票问题,就像好多班在买票,前面如果有和自己买票的就可以插队,但是只能插到自己班的最后一名,如果没有自己班的排队买票就只能在所有人后面慢慢排队买票了,我采用了栈以及数组和链表,但是一般不要用stl,要不然很容易超时,第一次提交时完全用的stl所以超时了……下面是代码 第一次提交的代码,但是超时了……#include #include #include #include
2012-09-11 09:03:40 860
原创 11234 - Expressions
对于这道题,采用二叉树和层次遍历;刚开始做这道题确实不会,没看懂题,其实就死一个数学公式问题,按照题目所给出的公式就可以了 #include #include #include #include #include #include using namespace std;const int MAXN=10000;char s[MAXN+100];typedef struc
2012-09-11 09:01:54 511
原创 11111 - Generalized Matrioshkas
#include #include #include #include #include using namespace std;int main(){ char c; int x; vector v; v.clear(); //freopen("a.txt","r",stdin); while(scanf("%d%c",&x,&c)
2012-09-11 09:00:40 496
原创 442 - Matrix Chain Multiplication
#include #include #include #include using namespace std;typedef struct{ char mat_name; int row; int col;} Mat;typedef struct{ int r; int c;} News;int main(){// freo
2012-09-11 09:00:07 333
原创 673 - Parentheses Balance
#include #include #include #include using namespace std;int main(){ //freopen("a.txt","r",stdin); int i,n,flag; cin>>n; getchar(); while(n--) { char str[510],str1
2012-09-11 08:59:25 400
原创 10152 - ShellSort
#include #include #include using namespace std;int main(){ //freopen("a.txt","r",stdin); char str[210][85],s[210][85]; int n,m,i,count; cin>>n; while(n--) { cin>>m
2012-09-11 08:57:06 327
原创 133 - The Dole Queue
#include #include #include #include #include using namespace std;int main(){ //freopen("a.txt","r",stdin); int n,k,m,i,flag,sum; while(cin>>n>>k>>m) { if(n+k+m==0)break;
2012-09-11 08:56:28 358
原创 101 - The Blocks Problem
#include #include #include #include #include #include #include using namespace std;vector > l;int move(int a,int b,int c){ list::iterator p,p1; int t(0),k(0); for(int j=0; j<l.s
2012-09-11 08:55:50 338
原创 127 - "Accordian" Patience
#include #include #include #include #include using namespace std;typedef struct{ char c[2];} Stk;typedef vector v;bool judge(Stk a,Stk b){ if(a.c[0]==b.c[0]||a.c[1]==b.c[1])
2012-09-11 08:54:49 429
原创 10112 - Myacm Triangles
#include #include #include int num(int x1,int y1,int x2,int y2,int x3,int y3){ return ((y3-y1)*(x2-x1)-(y2-y1)*(x3-x1));}int main(){ int n,i,j,k,l,count,sum1,sum2,sum3,sum4,flag; in
2012-09-11 08:52:54 350
原创 10387 - Billiard
#include #include const double P=atan(1.0);int main(){ double a,b,s,m,n; while(scanf("%lf%lf%lf%lf%lf",&a,&b,&s,&m,&n)!=EOF) { if((double)(a+b+s+m+n)==0)break; printf("
2012-09-11 08:51:40 382
原创 375 - Inscribed Circles and Isosceles Triangles
#include #include const double P=acos(-1.0);int main(){ int n; double x,y,w,h,k; scanf("%d",&n); while(n--) { scanf("%lf%lf",&x,&y); w=x/(x+2*sqrt(x*x/4+y*y));
2012-09-11 08:50:57 399
原创 579 - ClockHands
#include #include int main(){ int x,y; char c; double n,m; while(scanf("%d%c%d",&x,&c,&y)!=EOF) { if(x==0&&y==0)break; n=y*6.0; m=x*30.0+y/2.0; m
2012-09-11 08:50:03 281
原创 10250 - The Other Two Trees
#include int main(){ double x1,y1,x2,y2; while(scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)!=EOF) printf("%.10lf %.10lf %0.10lf %.10lf",(y1-y2+x1+x2)/2,(x2-x1+y1+y2)/2,(y2-y1+x1+x2)/2,
2012-09-11 08:48:50 288
原创 10879 - Code Refactoring
#includeusing namespace std;int main(){ long long int n,k,i,j,flag; cin>>n; i=1; while(i<=n) { cin>>k; cout<<"Case #"<<i<<": "<<k; flag=0; for(j=
2012-09-11 08:45:29 419
原创 10392 - Factoring Large Numbers
#include #include using namespace std;int main(){ long long int n,i,j; int flag; while(cin>>n) { if(n==-1)break; flag=0; j=n; n=sqrt(n); for
2012-09-11 08:44:45 357
原创 10061 - How many zero's and how many digits ?
#include #include #include using namespace std;long su(long a,long b,long c){ long d(a); while(d%b==0&&d!=1) { d=d/b; c++; } return c;}void sc(long a,long b,
2012-09-11 08:44:05 941
原创 350 - Pseudo-Random Numbers
#include #include using namespace std;long c[100000];int main(){ long L,I,M,Z; long count,i(1),temp,flag; while(cin>>Z>>I>>M>>L) { if(Z==0&&I==0&&M==0&&L==0)break;
2012-09-11 08:41:23 353
原创 408 - Uniform Generator
#include int main(){ //freopen("a.txt","r",stdin); long n,m,temp; while(scanf("%ld%ld",&n,&m)!=EOF) { printf("%10ld%10ld",n,m); if(n>m) { temp=m;
2012-09-10 10:12:22 387
原创 568 - Just the Facts
#include long s(long x){ for(int i=0;; i++) if(x%10==0)x/=10; else break; return x;}int main(){ //freopen("a.txt","r",stdin); long n,i; unsigned long long coun
2012-09-10 10:11:02 339
原创 550 - Multiplying by Rotation
#include using namespace std;int main(){ long n,x,y,temp,count,i,flag; while(cin>>n>>x>>y) { temp=x; count=flag=0; while(1) { if(y*temp+flag=
2012-09-10 10:10:11 404
原创 10110 - Light, more light
#include #include using namespace std;int main(){ long n,x; while(cin>>n) { if(n==0)break; x=sqrt(n); if(x*x==n)cout<<"yes"<<endl; else cout<<"no"<<endl
2012-09-10 10:09:28 328
原创 575 - Skew Binary
#include #include #include using namespace std;int main(){ long i,count; char s[1000]; memset(s,0,sizeof(s)); while(cin>>s) { if(s[0]=='0'&&strlen(s)==1)break;
2012-09-10 10:08:34 317
原创 10014 - Simple calculations
#include int main(){ //freopen("a.txt","r",stdin); int n,m,i; double a,b,c,count; scanf("%d",&n); while(n--) { scanf("%d",&m); scanf("%lf%lf",&a,&b);
2012-09-10 10:07:13 379
原创 10970 - Big Chocolate
#include using namespace std;int main(){ int n,m; while(cin>>n>>m) cout<<n*m-1<<endl; return 0;}
2012-09-10 10:05:51 306
原创 10916 - Factstone Benchmark
#include #include using namespace std;int main(){ int y,i,x(4); double count; while(cin>>y) { if(y==0)break; y=(y-1960)/10; for(i=0; i<y; i++) x
2012-09-10 10:05:06 344
原创 10177 - (2/3/4)-D Sqr/Rects/Cubes/Boxes?
#include long int xx(int x){ long long int sum(0); for(int y=1; y<=x; y++) sum+=y*y*y*y; return sum;}long int xxx(int x){ long long int sum(0); for(int y=1; y<=x; y++)
2012-09-10 10:04:17 975
原创 10719 - Quotient Polynomial
#include #include int main(){ //freopen("a.txt","r",stdin); int i,count,k; long int f[10010],l[10010]; char c; while(scanf("%d",&k)!=EOF) { count=0; memset(f
2012-09-10 10:03:21 366
原创 11044 - Searching for Nessy
#include using namespace std;int main(){ int n,x,y; cin>>n; while(n--) { cin>>x>>y; x=x/3; y=y/3; cout<<x*y<<endl; } return 0;}
2012-09-10 10:02:39 338
原创 10790 - How Many Points of Intersection?
#include using namespace std;int main(){ long long int x,y; long long int i,count,j,flag; j=1; while(cin>>x>>y) { if(x==0&&y==0)break; else {
2012-09-10 10:01:12 323
原创 10499 - The Land of Justice
#include using namespace std;int main(){ long long int x; while(cin>>x) if(x<=0)break; else if(x==1)cout<<"0%"<<endl; else cout<<25*x<<"%"<<endl; return 0;}
2012-09-10 10:00:15 315
原创 846 - Steps
#include using namespace std;int main(){ int n,x,y; int i,j; cin>>n; while(n--) { cin>>x>>y; if(y==x)cout<<"0"<<endl; else if(y-x==1)cout<<"1"<<endl;
2012-09-10 09:59:40 320
空空如也
C++11奇妙的未定义行为??
2014-09-21
C# 窗口移动,文字显示
2014-05-22
侯捷stl源码剖析红黑树代码问题
2014-04-07
python创建sql server 数据库问题求助
2013-12-25
sublime text3代码中自动对齐问题
2013-09-16
TA创建的收藏夹 TA关注的收藏夹
TA关注的人