結果
| 問題 | No.2117 中国剰余定理入門 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-04 22:04:53 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 2,000 ms |
| コード長 | 764 bytes |
| 記録 | |
| コンパイル時間 | 523 ms |
| コンパイル使用メモリ | 110,968 KB |
| 実行使用メモリ | 137,076 KB |
| 最終ジャッジ日時 | 2026-04-02 12:18:39 |
| 合計ジャッジ時間 | 1,692 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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");
}
}