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 |
求DEBUGIn Reply To:这难道不是水题吗。。。。。。为什么老是wa Posted by:yangyangyang91 at 2011-07-19 14:17:58 #include<iostream> using namespace std; int a,b; void swap(int & a,int & b) { if(a<b) { a=a^b; b=a^b; a=a^b; } } int gcd(int a,int b) { if(a%b==0) return b; else return gcd(b,a%b); } int lcm(int a,int b) { return a*b/gcd(a,b); } int key(int a,int b) { swap(a,b); if(a%b==0) return a/b; else { int ans=lcm(a,b); return ans*ans/a/b; } } int main() { while(scanf("%d %d",&a,&b),a||b) { cout<<key(a,b)<<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