結果
| 問題 |
No.2117 中国剰余定理入門
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-04 22:04:53 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 764 bytes |
| コンパイル時間 | 2,142 ms |
| コンパイル使用メモリ | 105,472 KB |
| 実行使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2024-07-18 19:51:08 |
| 合計ジャッジ時間 | 2,220 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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();
static void Main()
{
Solve();
}
static void Solve()
{
var a0 = NList;
var a1 = NList;
a0[1] %= a0[0];
a1[1] %= a1[0];
if (a0[1] < 0) a0[1] += a0[0];
if (a1[1] < 0) a1[1] += a1[0];
for (var i = 0; i <= a0[0] * a1[0]; ++i)
{
if (i % a0[0] == a0[1] && i % a1[0] == a1[1])
{
WriteLine(i);
return;
}
}
WriteLine("NaN");
}
}