1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #include <stdio.h> int gcd(int p, int q){ if(q==0) return p; return gcd(q, p%q); } int lcm(int p, int q){ return p * q / gcd(p,q); } int main(int argc, char** argv){ int A, B; setbuf(stdout, NULL); scanf("%d %d",&A,&B); printf("%d %d\n",gcd(A,B),lcm(A,B)); return 0; }
|