結果

問題 No.2104 Multiply-Add
ユーザー mkawa2mkawa2
提出日時 2022-10-21 23:50:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,452 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 71,788 KB
最終ジャッジ日時 2023-09-13 23:57:57
合計ジャッジ時間 7,751 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 81 ms
71,388 KB
testcase_02 AC 80 ms
71,428 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 79 ms
71,480 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 76 ms
71,368 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 77 ms
71,460 KB
testcase_18 AC 79 ms
71,280 KB
testcase_19 WA -
testcase_20 AC 76 ms
71,532 KB
testcase_21 AC 75 ms
71,132 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 78 ms
71,468 KB
testcase_26 WA -
testcase_27 AC 79 ms
71,468 KB
testcase_28 AC 81 ms
71,668 KB
testcase_29 AC 78 ms
71,500 KB
testcase_30 AC 79 ms
71,284 KB
testcase_31 AC 79 ms
71,664 KB
testcase_32 AC 76 ms
71,172 KB
testcase_33 AC 78 ms
71,536 KB
testcase_34 AC 77 ms
71,320 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)
    return tk

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


a, b, c, d = LI()

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