結果

問題 No.539 インクリメント
ユーザー teketeke5000teketeke5000
提出日時 2017-10-24 20:41:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 1,410 ms
コンパイル使用メモリ 162,004 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 13:11:31
合計ジャッジ時間 2,231 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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