結果

問題 No.442 和と積
ユーザー mban
提出日時 2016-11-13 11:18:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 31 ms / 1,000 ms
コード長 789 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 116,384 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-07-04 22:40:06
合計ジャッジ時間 2,524 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Magatro
{
   static long A, B;
    static void Main()
    {
        long[] ss = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        Array.Sort(ss);
        A = ss[0];
        B = ss[1];
        long G = GCD(A, B);
        long q = A / G;
        long w = B / G;
        long gg = GCD(q + w, q) * GCD(q + w, w) * GCD(q + w, G) * G;
        Console.WriteLine(gg);
        
        }
    static long GCD(params long[]ab)
    {
        Array.Sort(ab);
        long b = ab[0], a = ab[1];
        long r = a % b;
        while (r != 0)
        {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }
    
}
0