結果
| 問題 | No.3157 Nabeatsu | 
| コンテスト | |
| ユーザー |  ゼット | 
| 提出日時 | 2025-05-23 19:32:43 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 248 ms / 2,000 ms | 
| コード長 | 441 bytes | 
| コンパイル時間 | 229 ms | 
| コンパイル使用メモリ | 82,332 KB | 
| 実行使用メモリ | 169,412 KB | 
| 最終ジャッジ日時 | 2025-05-23 19:32:53 | 
| 合計ジャッジ時間 | 6,497 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 45 | 
ソースコード
S=input()
result=[]
N=len(S)
for i in range(N):
  if int(S[i])!=3:
    result.append(int(S[i]))
  else:
    result.append(2)
    for j in range(i+1,N):
      result.append(9)
    break
if sum(result)%3!=0:
  print(*result,sep='')
  exit()
for i in range(len(result)-1,-1,-1):
  if result[i]>0:
    result[i]-=1
    if result[i]==3:
      result[i]=2
    for j in range(i+1,len(result)):
      result[j]=9
    print(*result,sep='')
    exit()
            
            
            
        