题解 | #求最小公倍数#

求最小公倍数

https://www.nowcoder.com/practice/feb002886427421cb1ad3690f03c4242

// 注意类名必须为 Main, 不要有任何 package xxx 信息

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int a = in.nextInt();

        int b = in.nextInt();

        int c;

        if(a<=100 && b<=100){

            if(a%b==0 || b%a==0){

                System.out.println(Math.max(a, b));

            }else if(a%2==0 && b%2==0){

                c = Math.max(a, b);

                a = Math.min((a / 2), (b / 2));

                System.out.println(a*c);

            }else if(a%3==0 && b%3==0){

                c = Math.max(a, b);

                a = Math.min((a / 3), (b / 3));

                System.out.println(a*c);

            }else {

                System.out.println(a*b);

            }

        }

    }

}

全部评论

相关推荐

06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务