OJ--------最小公倍数+求解立方根
2016-08-11 21:03
211 查看
输入:俩个整数
输出:最小公倍数
样例:2 3
输出:6
求解立方根:
Math.cbrt(scanner.nextDouble());
输出:最小公倍数
样例:2 3
输出:6
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int a=sc.nextInt(); int b=sc.nextInt(); System.out.println(same(a,b)); } sc.close(); } private static int same(int a,int b){ int t=a>b?a:b; int sum=1; int i=1; while(!(sum%a==0&&sum%b==0)){ sum=t*i; i++; } return sum; } }
求解立方根:
Math.cbrt(scanner.nextDouble());
相关文章推荐
- 【华为 OJ 】求解立方根
- oj2003: C语言实验——最小公倍数和最大公约数
- 第十一周OJ——求两个整数的最大公约数和最小公倍数
- 递归:最小公倍数和最大公约数求解
- 使用Python求解最小公倍数
- 第十八周 【OJ问题 A: C++实验——最小公倍数和最大公约数】
- 【华为oj】求解立方根
- 【华为OJ】求解立方根
- 第十一周OJ5求两个整数的最大公约数和最小公倍数
- 第11周 oj 求两个整数的最大公约数和最小公倍数
- C/C++训练1---最大公约数与最小公倍数OJ
- OJ刷题之最小公倍数和最小公约数
- 华为OJ——求解立方根
- C语言三种算法求解最大公约数与最小公倍数
- 南阳oj 517 最小公倍数
- 华为OJ1964-求解立方根(牛顿迭代法)
- 第11周OJ实践 求最大公约数和最小公倍数
- oj:求两个数的最大公约数和最小公倍数
- 最小公倍数和最大公约数求解方法
- 【杭电oj】2028-Lowest Common Multiple Plus(最小公倍数)(水)