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<iostream.h> #include <math.h> int gcd(int a,int b) { return a == 0 ? b : gcd(b % a, a); } bool res(int m,int n) { if(m==1) return true; if(n==1&&m!=1) return false; int temp=gcd(m,n); return res(m/temp,n-1); } int main() { int m,n; while(cin>>m>>n) { if(n==0) cout<<n<<" does not divide "<<m<<"!"<<endl; else if(m==0||m==1) { if(n==1) cout<<"1 divides "<<m<<"!"<<endl; else cout<<n<<" does not divide "<<m<<"!"<<endl; } else { if(res(n,m)) cout<<n<<" divides "<<m<<"!"<<endl; else cout<<n<<" does not divide "<<m<<"!"<<endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator