結果

問題 No.2104 Multiply-Add
ユーザー mkawa2mkawa2
提出日時 2022-10-22 00:02:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,596 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 71,808 KB
最終ジャッジ日時 2023-09-14 00:05:39
合計ジャッジ時間 6,349 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 79 ms
71,444 KB
testcase_02 AC 78 ms
71,172 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 74 ms
71,412 KB
testcase_09 AC 74 ms
71,456 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 80 ms
71,232 KB
testcase_14 AC 78 ms
71,688 KB
testcase_15 AC 76 ms
71,444 KB
testcase_16 AC 80 ms
71,192 KB
testcase_17 WA -
testcase_18 AC 75 ms
71,468 KB
testcase_19 WA -
testcase_20 AC 76 ms
71,188 KB
testcase_21 AC 75 ms
71,420 KB
testcase_22 AC 79 ms
71,484 KB
testcase_23 AC 74 ms
71,728 KB
testcase_24 AC 77 ms
71,484 KB
testcase_25 AC 76 ms
71,116 KB
testcase_26 AC 78 ms
71,536 KB
testcase_27 AC 74 ms
71,696 KB
testcase_28 AC 74 ms
71,480 KB
testcase_29 AC 72 ms
71,336 KB
testcase_30 AC 74 ms
71,224 KB
testcase_31 AC 77 ms
71,500 KB
testcase_32 AC 74 ms
71,428 KB
testcase_33 AC 77 ms
71,564 KB
testcase_34 AC 72 ms
71,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

from math import gcd

def to10(a, b):
    tk = []
    while b:
        if a == 0:
            tk.append((1, 1))
            tk.append((2, -1))
            break
        if abs(a) > abs(b):
            k, a = divmod(a, b)
            # if a < 0:
            #     a -= b
            #     k += 1
            tk.append((1, -k))
        else:
            k, b = divmod(b, a)
            # if b < 0:
            #     b -= a
            #     k += 1
            tk.append((2, -k))
        # print(a,b)
    if a < 0:
        tk.append((2, 1))
        tk.append((1, -2))
        tk.append((2, 1))
    
    return tk

# a=-10
# b=9
# print(a%b)


a, b, c, d = LI()

if (a, b) == (c, d):
    print(0)
    exit()

if gcd(a, b) != gcd(c, d):
    print(-1)
    exit()

tk = to10(a, b)
rtk = to10(c, d)

tk += [(t, -k) for t, k in rtk[::-1]]
print(len(tk))
for t, k in tk: print(t, k)
0