結果
| 問題 | No.3278 Avoid Division | 
| コンテスト | |
| ユーザー |  ゼット | 
| 提出日時 | 2025-09-19 22:32:52 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 44 ms / 2,000 ms | 
| コード長 | 552 bytes | 
| コンパイル時間 | 344 ms | 
| コンパイル使用メモリ | 82,228 KB | 
| 実行使用メモリ | 58,812 KB | 
| 最終ジャッジ日時 | 2025-09-19 22:34:06 | 
| 合計ジャッジ時間 | 4,607 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 24 | 
ソースコード
N=int(input())
a,b=0,0
L=[]
for i in range(N):
  t,x=input().split()
  p='A['+str(i+1)+']'
  x=int(x)
  if t=='*':
    L.append(('mul','a','a',p))
    a*=x
  elif t=='+':
    if b>0:
      L.append(('mul','c',p,'b'))
      x*=b
    if b==0:
      L.append(('add','a','a',p))
    else:
      L.append(('add','a','a','c'))
    a+=x
  else:
    if b==0:
      L.append(('add','b','b',p))
      b+=x
    else:
      L.append(('mul','b','b',p))
      b*=x
if b>0:
  L.append(('div','a','a','b'))
print(len(L))
for i in range(len(L)):
  h=L[i][:]
  print(*h)
            
            
            
        