結果

問題 No.186 中華風 (Easy)
ユーザー flygonflygon
提出日時 2023-06-04 20:33:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 825 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 71,952 KB
最終ジャッジ日時 2023-08-28 08:24:02
合計ジャッジ時間 3,909 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,528 KB
testcase_01 AC 92 ms
71,556 KB
testcase_02 AC 92 ms
71,576 KB
testcase_03 AC 93 ms
71,604 KB
testcase_04 AC 90 ms
71,952 KB
testcase_05 AC 92 ms
71,600 KB
testcase_06 AC 91 ms
71,560 KB
testcase_07 AC 91 ms
71,416 KB
testcase_08 AC 90 ms
71,516 KB
testcase_09 AC 92 ms
71,280 KB
testcase_10 AC 91 ms
71,860 KB
testcase_11 AC 92 ms
71,432 KB
testcase_12 AC 90 ms
71,676 KB
testcase_13 AC 91 ms
71,832 KB
testcase_14 AC 90 ms
71,516 KB
testcase_15 AC 92 ms
71,416 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 88 ms
71,456 KB
testcase_19 AC 89 ms
71,444 KB
testcase_20 AC 91 ms
71,840 KB
testcase_21 AC 91 ms
71,436 KB
testcase_22 AC 91 ms
71,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from collections import defaultdict, deque, Counter
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline


def extgcd(a, b):
    if b == 0:
        return 1, 0, a
    q, r = a//b, a % b
    x, y, d = extgcd(b, r)
    s, t = y, x-y*q
    return s, t, d

def crt(b, m):
    r = 0
    M = 1
    for i in range(len(b)):
        s,t, d = extgcd(M, m[i])
        if (b[i] - r) % d != 0: 
            return [0, -1]
        lcm = M * m[i] // d
        r +=  M * ((b[i] - r) // d) * s
        M = lcm
        r %= M
    return r, M
        
x,y = map(int,input().split())
x2,y2 = map(int,input().split())
x3,y3 = map(int,input().split())

r,M = crt([x,x2,x3], [y,y2,y3])
if M != -1:
    print(r)
else:
    print(M)
0