1 solutions
-
0
C :
#include<stdio.h> #include<math.h> int yueshu(int a,int b) { int t; while(b) { t=a%b; a=b; b=t; } return a; } int beishu(int a,int b) { int t=yueshu(a,b); return a*b/t; } int main() { int i,j,a,b; scanf("%d%d",&a,&b); printf("%d %d",yueshu(a,b),beishu(a,b)); }
C++ :
#include<iostream> using namespace std; int gcd(int m,int n) { int r=m%n; while (r) { m=n; n=r; r=m%n; } return n; } int lcd(int m,int n) { return m*n/gcd(m,n); } int main() { int m,n; cin>>m>>n; cout<<gcd(m,n)<<" "<<lcd(m,n)<<endl; return 0; }
- 1
Information
- ID
- 2203
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By