結果

問題 No.539 インクリメント
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-29 14:20:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 3,145 ms
コンパイル使用メモリ 199,168 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-08-11 04:01:14
合計ジャッジ時間 3,114 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 37 ms
4,376 KB
testcase_02 AC 37 ms
4,376 KB
testcase_03 AC 38 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0