結果
問題 | No.186 中華風 (Easy) |
ユーザー | fmhr |
提出日時 | 2015-04-20 07:35:56 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 574 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 10,920 KB |
実行使用メモリ | 8,300 KB |
最終ジャッジ日時 | 2023-09-27 00:45:19 |
合計ジャッジ時間 | 1,522 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,144 KB |
testcase_01 | AC | 16 ms
7,908 KB |
testcase_02 | AC | 15 ms
7,828 KB |
testcase_03 | AC | 16 ms
7,844 KB |
testcase_04 | AC | 15 ms
7,796 KB |
testcase_05 | AC | 16 ms
7,804 KB |
testcase_06 | AC | 16 ms
7,888 KB |
testcase_07 | AC | 16 ms
7,832 KB |
testcase_08 | AC | 16 ms
7,920 KB |
testcase_09 | AC | 16 ms
7,804 KB |
testcase_10 | AC | 16 ms
8,212 KB |
testcase_11 | AC | 16 ms
7,836 KB |
testcase_12 | AC | 16 ms
7,784 KB |
testcase_13 | AC | 16 ms
7,844 KB |
testcase_14 | AC | 16 ms
7,832 KB |
testcase_15 | AC | 16 ms
7,848 KB |
testcase_16 | AC | 16 ms
7,924 KB |
testcase_17 | AC | 16 ms
7,836 KB |
testcase_18 | AC | 16 ms
7,788 KB |
testcase_19 | AC | 15 ms
8,164 KB |
testcase_20 | AC | 16 ms
8,292 KB |
testcase_21 | AC | 16 ms
8,300 KB |
testcase_22 | AC | 16 ms
8,228 KB |
ソースコード
# coding=utf-8 import sys def egcd(x, y): if y == 0: return (x, 1, 0) (d, a, b) = egcd(y, x % y) return (d, b, a - (x // y) * b) def crt(p, m, q, n): a, d, r = egcd(p, q) if (n - m) % a != 0: return (-1, -1) mod = p * (q // a) a = (d * ((n - m) // a) * p + m) % mod return (a, mod) def chinese_remainder(items): xx = 0 yy = 1 for x, y in items: xx, yy = crt(y, x, yy, xx) if xx == -1: print(-1) sys.exit(0) if xx == 0: xx = yy return xx n = 3 x = [0] * n for i in range(n): x[i] = tuple(map(int, input().split())) print(chinese_remainder(x))