結果

問題 No.2117 中国剰余定理入門
ユーザー 👑 kakel-sankakel-san
提出日時 2022-11-04 22:04:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 764 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 66,128 KB
実行使用メモリ 23,992 KB
最終ジャッジ日時 2023-09-26 00:29:41
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,992 KB
testcase_01 AC 61 ms
21,936 KB
testcase_02 AC 61 ms
21,764 KB
testcase_03 AC 61 ms
19,744 KB
testcase_04 AC 60 ms
21,832 KB
testcase_05 AC 59 ms
21,956 KB
testcase_06 AC 59 ms
22,044 KB
testcase_07 AC 59 ms
23,788 KB
testcase_08 AC 59 ms
21,960 KB
testcase_09 AC 59 ms
23,852 KB
testcase_10 AC 59 ms
22,044 KB
testcase_11 AC 60 ms
21,816 KB
testcase_12 AC 58 ms
21,912 KB
testcase_13 AC 60 ms
21,968 KB
testcase_14 AC 59 ms
21,984 KB
testcase_15 AC 59 ms
21,868 KB
testcase_16 AC 60 ms
23,920 KB
testcase_17 AC 60 ms
21,896 KB
testcase_18 AC 59 ms
23,852 KB
testcase_19 AC 59 ms
21,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
    }
}
0