1 solutions
-
0
C :
#include<stdio.h> int LCM(int n,int m); int main() { int a,b; scanf("%d,%d",&a,&b); printf("%d\n",LCM(a,b)); return 0; } int LCM(int n,int m) { int x; int find=0; for(x=1;!find;x++) { if(x%n==0&&x%m==0) { find=1; } } return x-1; }C++ :
#include<iostream> #include<cstdio> using namespace std; int gbs(int a,int b) { int r,s=a*b; if(a>b) { r=a%b; while(r!=0) { a=b; b=r; r=a%b; } return s/b; } else { r=b%a; while(r!=0) { b=a; a=r; r=b%a; } return s/a; } } int main() { int x,y; scanf("%d,%d",&x,&y); gbs(x,y); cout<<gbs(x,y); return 0; }
- 1
Information
- ID
- 17190
- Time
- 1000ms
- Memory
- 2MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By