結果

問題 No.442 和と積
ユーザー mbanmban
提出日時 2016-11-13 11:18:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 1,000 ms
コード長 789 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 104,348 KB
実行使用メモリ 23,932 KB
最終ジャッジ日時 2023-09-18 06:28:14
合計ジャッジ時間 4,732 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
23,852 KB
testcase_01 AC 61 ms
23,864 KB
testcase_02 AC 60 ms
21,804 KB
testcase_03 AC 61 ms
21,924 KB
testcase_04 AC 61 ms
21,792 KB
testcase_05 AC 61 ms
21,868 KB
testcase_06 AC 62 ms
21,808 KB
testcase_07 AC 62 ms
21,908 KB
testcase_08 AC 61 ms
23,768 KB
testcase_09 AC 61 ms
21,812 KB
testcase_10 AC 61 ms
21,848 KB
testcase_11 AC 62 ms
23,932 KB
testcase_12 AC 62 ms
23,880 KB
testcase_13 AC 60 ms
19,736 KB
testcase_14 AC 62 ms
21,852 KB
testcase_15 AC 61 ms
21,748 KB
testcase_16 AC 61 ms
21,936 KB
testcase_17 AC 61 ms
23,792 KB
testcase_18 AC 61 ms
21,848 KB
testcase_19 AC 61 ms
21,980 KB
testcase_20 AC 60 ms
21,780 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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