Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
帮我看下哪里错了?为什么一直超时????#include "stdio.h" #include "string.h" main() { int a,b,c,d,x,y,i,temp,z,t,v,w; char s[7],fu; while(scanf("%s",&s)!=EOF) { a=s[0]-48; b=s[2]-48; fu=s[3]; c=s[4]-48; d=s[6]-48; if (fu=='-') c=-c; y=b*d; x=a*d+b*c; z=y; t=x; if(t==0||z==1) printf("%d\n",t); else if(t==z) printf("%d\n",1); else { while(y!=0) { if(x>y) { temp=x%y; x=y; } else temp=y%x; y=temp; } w=z/x; v=t/x; if(w<0&&v>0) printf("-%d/%d\n",v,(-w)); else printf("%d/%d\n",v,w); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator