luanpaixie262 于 2016.03.23 14:40 提问

5个回答

yue1123   2016.03.23 14:56

luanpaixie262 回复yue1123: 源码怎么写
2 年多之前 回复
weixin_32769751   2016.03.23 14:58

luanpaixie262 回复weixin_32769751: 源码呢
2 年多之前 回复
LiChaoxi   2016.03.23 15:13

import java.util.Scanner;

public class Test2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a, b, c;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
System.out.println(calcWalnutNum(a, b, c));
sc.close();
}

``````public static int calcWalnutNum(int a, int b, int c) {
return getLCM(getLCM(a, b), c);
}

public static int getLCM(int a, int b) {
int c = a * b;
int r = 0;
if (a < b) {
r = a;
a = b;
b = r;
}
while ((r = a % b) != 0) {
a = b;
b = r;
}
return c / b;
}
``````

}

enpterexpress   2016.03.23 15:44
``````        static void Main(string[] args)
{
int res = m(a, b, c);
Console.WriteLine(res);
}

static int f(int a, int b)
{
if (a < b)
{
a = a + b;
b = a - b;
a = a - b;
}
return (a % b == 0) ? b : f(a % b, b);
}

static int m(int a, int b)
{
return a * b / f(a, b);
}

static int m(int a, int b, int c)
{
return m(m(a, b), c);
}
``````
huixion   2016.03.23 19:08

``````public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=scan.nextInt();

long i=2;
while(i%a!=0||i%b!=0||i%c!=0)
{
i++;
}
System.out.println(i);
}
``````