結果

問題 No.539 インクリメント
ユーザー teketeke5000teketeke5000
提出日時 2017-10-24 20:50:21
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 839 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 162,824 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-05-01 13:12:31
合計ジャッジ時間 5,219 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 42 ms
6,940 KB
testcase_02 AC 42 ms
6,940 KB
testcase_03 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int T;
    int level;
    cin >> T;
    string strs[T];
    cin.ignore();
    for (int i=0; i<T; i++) {
        string str;
        getline(cin, str);
        bool up = false;
        for (int j=str.size()-1; j>=0; j--) {
            int num = (int)str[j] - '0';
            if (num == 9) {
                str[j] = '0';
                up = true;
                str = j == 0 ? '1' + str : str;
                continue;
            }
            if (0<= num && num < 9) {
                str[j] = (char)num + '0' + 1;
                break;
            } else if (up) {
                str.insert(str.begin() + j + 1, '1');
                break;
            }
        }
        strs[i] = str;
    }
    for (int i=0; i<T; i++) cout << strs[i] << endl;
    return 0;
}
0