結果

問題 No.2117 中国剰余定理入門
ユーザー bluemeganebluemegane
提出日時 2022-11-05 06:42:46
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 827 bytes
コンパイル時間 1,250 ms
コンパイル使用メモリ 63,372 KB
実行使用メモリ 22,900 KB
最終ジャッジ日時 2023-09-26 07:40:24
合計ジャッジ時間 3,447 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,856 KB
testcase_01 AC 60 ms
18,724 KB
testcase_02 AC 60 ms
20,732 KB
testcase_03 AC 61 ms
20,692 KB
testcase_04 AC 58 ms
20,700 KB
testcase_05 AC 60 ms
20,744 KB
testcase_06 AC 59 ms
22,824 KB
testcase_07 AC 58 ms
22,712 KB
testcase_08 AC 57 ms
20,776 KB
testcase_09 AC 61 ms
22,900 KB
testcase_10 AC 60 ms
22,852 KB
testcase_11 AC 60 ms
20,800 KB
testcase_12 AC 65 ms
20,732 KB
testcase_13 AC 61 ms
20,792 KB
testcase_14 AC 57 ms
20,800 KB
testcase_15 AC 61 ms
22,744 KB
testcase_16 AC 60 ms
18,748 KB
testcase_17 AC 59 ms
20,732 KB
testcase_18 AC 59 ms
20,688 KB
testcase_19 AC 59 ms
20,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var b0 = int.Parse(line[0]);
        var c0 = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var b1 = int.Parse(line[0]);
        var c1 = int.Parse(line[1]);
        getAns(b0, c0, b1, c1);
    }
    static void getAns(int b0, int c0, int b1, int c1)
    {

        while (c0 < 0) c0 += b0;
        while (c1 < 0) c1 += b1;
        while (c0 >= b0) c0 -= b0;
        while (c1 >= b1) c1 -= b1;
        for (int i = 0; i < b0 * b1; i++)
        {
            if (i % b0 == c0 && i % b1 == c1) { Console.WriteLine(i); return; }
        }
        Console.WriteLine("NaN");
    }
}
0