結果

問題 No.2117 中国剰余定理入門
ユーザー 👑 chro_96chro_96
提出日時 2022-11-04 21:27:27
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 28,240 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-25 23:40:48
合計ジャッジ時間 1,365 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,500 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 0 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int b0 = 0;
  int c0 = 0;
  int b1 = 0;
  int c1 = 0;
  
  int res = 0;
  
  int ans = 0;
  
  res = scanf("%d", &b0);
  res = scanf("%d", &c0);
  res = scanf("%d", &b1);
  res = scanf("%d", &c1);
  
  if (c0 < 0) {
    c0 += (1+(-c0)/b0)*b0;
  }
  if (c1 < 0) {
    c1 += (1+(-c1)/b1)*b1;
  }
  
  while (ans < b0*b1) {
    if (ans%b0 == c0%b0 && ans%b1 == c1%b1) {
      printf("%d\n", ans);
      return 0;
    }
    ans++;
  }
  
  printf("NaN\n");
  return 0;
}
0