結果
問題 | No.539 インクリメント |
ユーザー |
|
提出日時 | 2019-08-29 14:20:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 1,875 ms |
コンパイル使用メモリ | 193,844 KB |
最終ジャッジ日時 | 2025-01-07 15:33:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;int main() {int t;cin>>t;cin.ignore();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;}