結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2017-07-11 02:33:24 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 777 ms / 2,000 ms |
| コード長 | 628 bytes |
| コンパイル時間 | 175 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-10-07 13:58:02 |
| 合計ジャッジ時間 | 3,047 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
import string
def inc(s):
carry = len(s) > 0
ret = ""
for c in s[::-1]:
if not carry:
ret += c
elif c == '9':
ret += '0'
else:
ret += str(int(c) + 1)
carry = False
if carry:
ret += '1'
return ret[::-1]
n = int(input())
for j in range(n):
s = input()
l = 0
r = -1
digit = False
for i,c in enumerate(s):
if c in string.digits:
r = i
if not digit:
l = i
digit = True
else:
digit = False
print(s[:l] + inc(s[l:r+1]) + s[r+1:])
h_noson