結果
問題 | No.2117 中国剰余定理入門 |
ユーザー | bluemegane |
提出日時 | 2022-11-05 06:42:46 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 827 bytes |
コンパイル時間 | 3,075 ms |
コンパイル使用メモリ | 103,424 KB |
実行使用メモリ | 17,792 KB |
最終ジャッジ日時 | 2024-07-19 02:47:26 |
合計ジャッジ時間 | 4,257 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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"); } }