結果

問題 No.3157 Nabeatsu
ユーザー i_taku
提出日時 2025-05-27 14:30:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 176,336 KB
最終ジャッジ日時 2025-05-27 14:30:44
合計ジャッジ時間 7,605 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 35 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.set_int_max_str_digits(0)


N = input()
for _ in range(2):
    ans = ['9'] * len(N)
    res = 9 * len(N)
    for i, n in enumerate(N):
        if n == '3':
            res -= 7
            ans[i] = '2'
            break
        else:
            res -= 9 - int(n)
            ans[i] = n

    if res % 3 == 0:
        if ans[-1] == '0':
            ans = int(''.join(ans))
            ans -= 1
        else:
            ans[-1] = str(int(ans[-1]) - 1)
            break
    else:
        ans = ''.join(ans)
        break
    N = str(ans)

print(ans)
0