結果
問題 |
No.3157 Nabeatsu
|
ユーザー |
![]() |
提出日時 | 2025-05-23 20:09:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 147 ms / 2,000 ms |
コード長 | 1,094 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 82,448 KB |
実行使用メモリ | 127,888 KB |
最終ジャッジ日時 | 2025-05-23 20:09:42 |
合計ジャッジ時間 | 6,085 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
import sys, time, random, heapq, math, itertools from collections import deque, Counter, defaultdict #from sortedcontainers import SortedSet, SortedList from bisect import bisect, bisect_left, bisect_right import heapq as hq from functools import cache, cmp_to_key def debug(*x):print('debug:',*x, file=sys.stderr) sys.setrecursionlimit(300000) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 N = list(input()) def d(): global N for i in range(len(N)-1,-1,-1): if N[i] == "0": N[i] = "9" continue else: N[i] = str(int(N[i]) - 1) if N[i] == "3": N[i] = str(int(N[i]) - 1) return 0 for i in range(len(N)): if N[i] == "3": N[i] = "2" for j in range(i+1,len(N)): N[j] = "9" break cnt = 0 for i in range(len(N)): cnt += int(N[i]) cnt %=3 if cnt % 3 == 0: d() ans = "".join(N) print(ans) else: print("".join(N))