結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-29 14:18:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 616 bytes |
| コンパイル時間 | 2,241 ms |
| コンパイル使用メモリ | 193,496 KB |
| 最終ジャッジ日時 | 2025-01-07 15:33:40 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int t;
cin>>t;
while (t--) {
string s;
getline(cin,s);
int i=s.size()-1;
while (0<=i&&!isdigit(s[i]))
i--;
int carry=0;
while (0<=i&&isdigit(s[i])) {
if (s[i]=='9') {
s[i]='0';
carry=1;
i--;
} else {
carry=0;
s[i]++;
break;
}
}
if (carry)
s.insert(i+1,"1");
cout<<s<<endl;
}
return 0;
}