結果
| 問題 | No.539 インクリメント | 
| コンテスト | |
| ユーザー |  けーむ | 
| 提出日時 | 2020-08-14 11:29:09 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 25 ms / 2,000 ms | 
| コード長 | 1,905 bytes | 
| コンパイル時間 | 1,518 ms | 
| コンパイル使用メモリ | 170,040 KB | 
| 実行使用メモリ | 6,816 KB | 
| 最終ジャッジ日時 | 2024-10-10 11:43:44 | 
| 合計ジャッジ時間 | 2,784 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
void solve() {
    string s;
    getline(cin, s);
    string before = "", value = "", after = "";
    bool found = false;
    rrep(i, len(s)) {
        if (found) {
            if ((s[i] >= '0') && (s[i] <= '9')) {
                if (before == "") {
                    value += s[i];
                }
                else {
                    before += s[i];
                }
            }
            else {
                before += s[i];
            }
        }
        else {
            if ((s[i] >= '0') && (s[i] <= '9')) {
                found = true;
                value += s[i];
            }
            else {
                after += s[i];
            }
        }
    }
    if (value != "") {
        ll rem = 1;
        rep(i, len(value)) {
            if (value[i] == '9') {
                value[i] = '0';
            }
            else {
                value[i] = (char)(value[i] + 1);
                rem = 0;
                break;
            }
        }
        if (rem == 1) {
            value += '1';
        }
    }
    reverse(all(before));
    reverse(all(value));
    reverse(all(after));
    printf("%s%s%s\n", before.c_str(), value.c_str(), after.c_str());
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string st;
    getline(cin, st);
    ll t = atoi(st.c_str());
    rep(i, t) solve();
    return 0;
}
            
            
            
        