题解 | #求最小公倍数#

求最小公倍数

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

#include <bits/types/struct_tm.h>
#include <cstddef>
#include <iostream>
using namespace std;

int main() {
    int a, b;
    while (cin >> a >> b) { // 注意 while 处理多个 case
        size_t tmax = a * b;
        int ans = tmax;
        for (int i = tmax;i >= a;i--) {
            if (i % a == 0 && i % b == 0) {
                ans = min(ans, i);
            }
        }
        cout << ans <<  endl;
    }
}

全部评论

相关推荐

真的很糟糕:不一定是你的问题,当然你也可以做的更好一些,继续投相信自己一定会有的
点赞 评论 收藏
分享
迷茫的大四🐶:哇靠,哥们,啥认证啊,副总裁实习,这么有实力嘛
一起聊美团
点赞 评论 收藏
分享
阿武同学:内容很多,但是要突出重点,语言精简下,缩到一页
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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