結果
| 問題 | No.539 インクリメント |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-02 19:48:13 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 899 bytes |
| 記録 | |
| コンパイル時間 | 604 ms |
| コンパイル使用メモリ | 70,480 KB |
| 実行使用メモリ | 10,664 KB |
| 最終ジャッジ日時 | 2024-10-02 07:29:38 |
| 合計ジャッジ時間 | 4,402 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 TLE * 1 -- * 1 |
ソースコード
#include<iostream>
#include<cctype>
using namespace std;
int main(){
int t;
scanf("%d\n", &t);
while(t-- > 0){
string s;
getline(cin, s);
string res = "";
for(int i = s.length()-1; i >= 0; i--){
if(isdigit(s[i])){
int carry = 1;
while(i >= 0 && isdigit(s[i])){
int val = carry + (s[i] - '0');
carry = val/10;
val %= 10;
char next = '0' + val;
string t{next};
res = t + res;
i--;
}
i++;
if(carry) res = "1" + res;
res = s.substr(0, i) + res;
break;
}else{
res = s.substr(i,1) + res;
}
}
cout << res << endl;
}
return 0;
}