题解 | #求最小公倍数#

求最小公倍数

https://www.nowcoder.com/practice/22948c2cad484e0291350abad86136c3

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import static java.util.Arrays.*;
import static java.util.stream.Stream.*;


public class Main {
    public static void main(String[] args) throws IOException {

        testTh();
    }
    private static void testTh() throws IOException {
        BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
        String str;
        StringBuilder sb=new StringBuilder();
        while ((str=bf.readLine())!=null){
            String[] s = str.split(" ");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);
            int flag=0;
            if (a%b==0){
                flag=1;
                System.out.println(a);
            }
            else if (b%a==0){
                flag=1;
                System.out.println(b);
            }
            if (flag==0){
                if (a*b/2%a==0&&a*b/2%b==0) System.out.println(a*b/2);
                else if (a*b/3%a==0&&a*b/3%b==0) System.out.println(a*b/3);
                else System.out.println(a*b);
            }
        }

        }


    }

全部评论

相关推荐

11-12 14:30
已编辑
广东科技学院 前端工程师
迷茫的小刺猬在迎接o...:前端岗位越来越少了,中小厂也更倾向全栈了,更不需要初级或者实习。可能就大厂才会有一些岗位,但是很看学历。
实习,投递多份简历没人回...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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