結果

問題 No.3278 Avoid Division
ユーザー navel_tos
提出日時 2025-09-20 03:37:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 743 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 82,600 KB
実行使用メモリ 54,400 KB
最終ジャッジ日時 2025-09-20 03:37:50
合計ジャッジ時間 4,380 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder3278 Avoid Division

def solve():
    N = int(input())
    bunbo_flag = 0
    ans = []
    for i in range(1, N + 1):
        op, _ = input().split()
        if   op == '+':
            if bunbo_flag == 0:
                ans.append(f'add a a A[{i}]')
            else:
                ans.append(f'mul c b A[{i}]')
                ans.append(f'add a a c')
        elif op == '*':
            ans.append(f'mul a a A[{i}]')
        elif op == '/':
            if bunbo_flag == 0:
                ans.append(f'add b b A[{i}]')
                bunbo_flag = 1
            else:
                ans.append(f'mul b b A[{i}]')
    if bunbo_flag == 1:
        ans.append(f'div a a b')
    print(len(ans))
    print(*ans, sep = '\n')

solve()
0