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

## m为0

Posted by luoxiaomao at 2007-02-28 15:43:57 on Problem 2649
In Reply To:为什么会Runtime error呀，帮忙呀！！！！！！！！！！！！！！！ Posted by:ecjtubaowp at 2007-02-28 14:20:10
```> #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: