結果
| 問題 | No.539 インクリメント |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-02 19:57:40 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 1,026 bytes |
| 記録 | |
| コンパイル時間 | 836 ms |
| コンパイル使用メモリ | 69,332 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-02 07:46:19 |
| 合計ジャッジ時間 | 1,720 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include<iostream>
#include<cctype>
#include<algorithm>
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;
i--;
}
if(carry) res += "1";
string rest = s.substr(0, ++i);
reverse(rest.begin(), rest.end());
res += rest;
break;
}else{
res += s.substr(i,1);
}
}
reverse(res.begin(), res.end());
cout << res << endl;
}
return 0;
}