結果
問題 | No.539 インクリメント |
ユーザー |
|
提出日時 | 2017-06-30 23:28:13 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 872 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 70,400 KB |
最終ジャッジ日時 | 2024-10-04 21:35:03 |
合計ジャッジ時間 | 1,007 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 RE * 2 |
ソースコード
def solve(s):idx = len(s)flag = Falselast = 0for c in s[::-1]:idx -= 1if '0' <= c and c <= '9':if not flag:flag = Truelast = idx + 1elif flag:first = idx + 1incremented = s[:first] + increment(s[first:last]) + s[last:]return incrementedif flag:first = 0incremented = s[:first] + increment(s[first:last]) + s[last:]return incrementedreturn sdef increment(s):ints = int(s)n = len(s)numn = len(str(ints))incremented = str(ints + 1)if numn == len(incremented):return '0' * (n - numn) + incrementedif s[0] == '0':return '0' * (n - numn - 1) + incrementedreturn incrementedn = int(input())for i in range(n):s = input()print(solve(s))