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

为什么会Runtime error呀,帮忙呀!!!!!!!!!!!!!!!

Posted by ecjtubaowp at 2007-02-28 14:20:10 on Problem 2649
#include<stdio.h>
int gcd(int a,int b)
{
 if(b==0)return a;
 else return gcd(b,a%b);
}
int solve(int n,int m)
{int div;
 if(m==1)return 1;
 if(n==1&&m!=1)return 0;
 div=gcd(m,n);
 return solve(n-1,m/div);
}
int main()
{
 int i,j,k,m,n;
 while(scanf("%d%d",&n,&m)==2)
 {
  if(m==0){printf("0 does not divide %d!\n",n);continue;}
  
  if(n==0||n==1)
  {
   if(m==1)printf("1 divides %d!\n",n);
   else printf("%d does not divide %d!\n",m,n);
   continue;
  }
  if(n>=m){printf("%d divides %d!\n",m,n);continue;}
  k=solve(n,m);
  if(k)printf("%d divides %d!\n",m,n);
  else printf("%d does not divide %d!\n",m,n);
  
 }
}


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