結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,432 KB
testcase_01 AC 73 ms
71,688 KB
testcase_02 AC 75 ms
71,396 KB
testcase_03 AC 76 ms
71,320 KB
testcase_04 AC 76 ms
71,696 KB
testcase_05 AC 73 ms
71,192 KB
testcase_06 AC 75 ms
71,624 KB
testcase_07 AC 74 ms
71,560 KB
testcase_08 AC 77 ms
71,564 KB
testcase_09 AC 74 ms
71,356 KB
testcase_10 AC 74 ms
71,320 KB
testcase_11 AC 76 ms
71,188 KB
testcase_12 AC 73 ms
71,316 KB
testcase_13 AC 76 ms
71,612 KB
testcase_14 AC 77 ms
71,436 KB
testcase_15 AC 75 ms
71,352 KB
testcase_16 AC 78 ms
71,488 KB
testcase_17 WA -
testcase_18 AC 76 ms
71,340 KB
testcase_19 AC 77 ms
71,540 KB
testcase_20 AC 76 ms
71,424 KB
testcase_21 AC 77 ms
71,184 KB
testcase_22 AC 75 ms
71,464 KB
testcase_23 AC 75 ms
71,320 KB
testcase_24 AC 78 ms
71,696 KB
testcase_25 AC 76 ms
71,488 KB
testcase_26 AC 76 ms
71,660 KB
testcase_27 AC 75 ms
71,384 KB
testcase_28 AC 75 ms
71,584 KB
testcase_29 AC 75 ms
71,436 KB
testcase_30 AC 74 ms
71,428 KB
testcase_31 AC 75 ms
71,424 KB
testcase_32 AC 75 ms
71,424 KB
testcase_33 AC 76 ms
71,184 KB
testcase_34 AC 74 ms
71,440 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