結果

問題 No.1987 Sandglass Inconvenience
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-06-24 22:35:17
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 715 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 71,692 KB
最終ジャッジ日時 2023-08-08 12:51:24
合計ジャッジ時間 3,153 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,492 KB
testcase_01 AC 65 ms
71,304 KB
testcase_02 AC 67 ms
71,516 KB
testcase_03 AC 70 ms
71,220 KB
testcase_04 AC 67 ms
71,352 KB
testcase_05 AC 70 ms
71,068 KB
testcase_06 AC 69 ms
71,540 KB
testcase_07 AC 66 ms
71,536 KB
testcase_08 AC 68 ms
71,348 KB
testcase_09 AC 67 ms
71,532 KB
testcase_10 AC 66 ms
71,204 KB
testcase_11 AC 66 ms
71,472 KB
testcase_12 AC 67 ms
71,208 KB
testcase_13 AC 67 ms
71,216 KB
testcase_14 AC 67 ms
71,492 KB
testcase_15 AC 67 ms
71,692 KB
testcase_16 AC 68 ms
71,204 KB
testcase_17 AC 65 ms
71,544 KB
testcase_18 AC 67 ms
71,224 KB
testcase_19 AC 66 ms
71,308 KB
testcase_20 AC 66 ms
71,380 KB
testcase_21 AC 67 ms
71,340 KB
testcase_22 AC 68 ms
71,540 KB
testcase_23 AC 67 ms
71,388 KB
testcase_24 AC 68 ms
71,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def extgcd(a, b):
    # ax + by = gcd(a,b)
    # return gcd(a,b), x, y
    if a == 0:
        return b, 0, 1
    else:
        g, x, y = extgcd(b % a, a)
        return g, y - (b // a) * x, x

def chineseRem(b1, m1, b2, m2):
    # x ≡ b1 (mod m1) ∧ x ≡ b2 (mod m2) <=> x ≡ r (mod m)
    # となる(r. m)を返す
    # 解無しのとき(0, -1)
    d, p, q = extgcd(m1, m2)
    if (b2 - b1) % d != 0:
        return 0, -1
    m = m1 * (m2 // d)  # m = lcm(m1, m2)
    tmp = (b2-b1) // d * p % (m2 // d)
    r = (b1 + m1 * tmp) % m
    return r, m


a,b,c = map(int,input().split())
X = int(input())

for _ in range(3):
    g = math.gcd(a,b)
    if g == 1 or X%g == 0:
        print("Yes")
        exit()
    if c%g == X%g:
        print("Yes")
        exit()

    if X%math.gcd(g,c) == 0:
        print("Yes")
        exit()
    a,b,c = c,a,b

if X%a*X%b*X%c:
    print("No")
else:
    print("Yes")
0