結果
| 問題 | No.442 和と積 |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-11-29 15:54:49 |
| 言語 | C# (.NET 10.0.403 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 40 ms / 1,000 ms |
| + 349µs | |
| コード長 | 847 bytes |
| 記録 | |
| コンパイル時間 | 7,241 ms |
| コンパイル使用メモリ | 174,064 KB |
| 実行使用メモリ | 32,512 KB |
| 最終ジャッジ日時 | 2026-11-29 15:55:00 |
| 合計ジャッジ時間 | 10,506 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (199 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
static int NN => int.Parse(ReadLine());
static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
public static void Main()
{
Solve();
}
static void Solve()
{
var c = NList;
if (c[0] > c[1]) (c[0], c[1]) = (c[1], c[0]);
var gcd = GCD(c[0], c[1]);
if (gcd == c[0])
{
var x = c[1] / c[0];
WriteLine(c[0] * GCD(x + 1, c[0]));
}
else
{
WriteLine(gcd * GCD(c[0] / gcd + c[1] / gcd, gcd));
}
}
static long GCD(long a, long b)
{
if (a < b) return GCD(b, a);
if (a % b == 0) return b;
return GCD(b, a % b);
}
}