Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮我看下哪里错了?为什么一直超时????

Posted by 1008063102 at 2011-07-18 15:17:13 on Problem 3979
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator