結果

問題 No.442 和と積
ユーザー ixTL255ixTL255
提出日時 2017-01-22 03:01:57
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 37 ms / 1,000 ms
コード長 456 bytes
コンパイル時間 798 ms
コンパイル使用メモリ 113,796 KB
実行使用メモリ 28,040 KB
最終ジャッジ日時 2024-07-04 22:56:33
合計ジャッジ時間 2,301 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.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