結果

問題 No.442 和と積
ユーザー ixTL255ixTL255
提出日時 2017-01-22 03:01:57
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 72 ms / 1,000 ms
コード長 456 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 107,676 KB
実行使用メモリ 24,208 KB
最終ジャッジ日時 2023-09-18 06:45:17
合計ジャッジ時間 4,643 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
24,072 KB
testcase_01 AC 67 ms
22,004 KB
testcase_02 AC 67 ms
20,052 KB
testcase_03 AC 68 ms
20,136 KB
testcase_04 AC 68 ms
21,992 KB
testcase_05 AC 68 ms
20,148 KB
testcase_06 AC 68 ms
24,088 KB
testcase_07 AC 68 ms
22,092 KB
testcase_08 AC 68 ms
22,032 KB
testcase_09 AC 70 ms
24,148 KB
testcase_10 AC 68 ms
24,020 KB
testcase_11 AC 71 ms
22,072 KB
testcase_12 AC 71 ms
24,068 KB
testcase_13 AC 72 ms
22,124 KB
testcase_14 AC 70 ms
24,100 KB
testcase_15 AC 71 ms
22,008 KB
testcase_16 AC 68 ms
20,172 KB
testcase_17 AC 68 ms
22,064 KB
testcase_18 AC 70 ms
24,208 KB
testcase_19 AC 68 ms
24,184 KB
testcase_20 AC 69 ms
22,132 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.Numerics;
using System.Linq;

public class Test
{
	public static void Main()
	{
		var x = Console.ReadLine().Split(' ')
			.Select(n => BigInteger.Parse(n)).ToArray();
	
		var a = x[0] + x[1];
		var b = x[0] * x[1];
		
		Console.WriteLine(Gcd(a, b));
	}
	
	private static BigInteger Gcd(BigInteger a, BigInteger b)
	{
		if(a < b) return Gcd(b, a);
		
		while(b != 0)
		{
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
}
0