题解 | #求最小公倍数#

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

#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int m,n;
    cin>>m>>n;
    int tmp;
    if (m<n){
        tmp=m;
        m=n;
        n=tmp;
    }
    int w;
    int v=1;
    if(m%n==0)
        w=m;
    else{ 
        for(int i=2;i<n;i++){
            if(n%i==0&&m%i==0)
              v=v*i;  
        }
        w=m*n/v;
    }
    cout<<w<<endl;
    return 0;
}
全部评论

相关推荐

tongx_:海投吧同学,面试中能学到更多东西呢,比如拷打项目,要是觉得没准备好就可以从中厂开始呢,但是腾讯都是无限复活
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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