import java.io.*; /** * 最小公约数:从两数中小的那个数开始找,直到找到一个可以同时被两数整除的数为止 * 最小公倍数:两数相乘再除以最小公约数 */ public class Main { public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); public static StreamTokenizer cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); public static PrintWriter cout = new PrintWriter(new OutputStreamWriter(System.out)); static int gongyueshu(int a, int b) { int i; if (a > b) { i = b; } else { i = a; } for ( ;i > 0; i--) { if ((a / i == (double) a / i) && (b / i == (double) b / i)) { break; } } return i; } static int gongbeishu(int a, int b) { return a * b / gongyueshu(a, b); } public static void main(String[] args) throws Exception { int a, b; cin.nextToken(); a = (int) cin.nval; cin.nextToken(); b = (int) cin.nval; cout.printf("%d %d", gongyueshu(a, b), gongbeishu(a, b)); cout.flush(); } }
0.0分
0 人评分
C语言训练-斐波纳契数列 (C语言代码)浏览:3015 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C++代码)(手动优化一下计算)浏览:1365 |
【回文数(二)】 (C语言代码)浏览:800 |
小明A+B (C语言代码)浏览:1317 |
printf基础练习2 (C语言代码)浏览:826 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:1015 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:723 |
【蟠桃记】 (C语言代码)浏览:1084 |
IP判断 (C语言描述,蓝桥杯)浏览:1118 |
1011题解浏览:819 |