题解 | #小乐乐与欧几里得#

小乐乐与欧几里得

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

using System;
public class Program {
    public static void Main() {
        string[] s = Console.ReadLine().Split(" ");
        Console.WriteLine(GCD(long.Parse(s[0]), long.Parse(s[1])) + FindLCM(long.Parse(s[0]), long.Parse(s[1])));

    }
    
    public static long GCD(long a,long b)
    {
        if(b == 0)
        {
            return a;
        }
        long temp = b;
        b = a % b;
        a = temp;
        return GCD(a, b);
    }

    public static long FindLCM(long a,long b)
    {
        return Math.Abs(a*b)/GCD(a,b);
    }
}

全部评论

相关推荐

06-20 17:42
东华大学 Java
凉风落木楚山秋:要是在2015,你这简历还可以月入十万,可惜现在是2025,已经跟不上版本了
我的简历长这样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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