結果
| 問題 | No.539 インクリメント |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-02 19:45:49 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 903 bytes |
| 記録 | |
| コンパイル時間 | 614 ms |
| コンパイル使用メモリ | 68,376 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-02 07:24:20 |
| 合計ジャッジ時間 | 5,105 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 1 -- * 2 |
ソースコード
#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 = "";
bool number = false;
for(int i = s.length()-1; i >= 0; i--){
if(!number && 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;
number = true;
}else{
res = s.substr(i,1) + res;
}
}
cout << res << endl;
}
return 0;
}