結果
| 問題 | No.539 インクリメント | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-11-02 17:04:42 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,152 bytes | 
| コンパイル時間 | 907 ms | 
| コンパイル使用メモリ | 95,868 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-22 06:22:54 | 
| 合計ジャッジ時間 | 2,275 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 1 WA * 2 | 
ソースコード
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		string s;
		do {
		getline(cin, s);
		} while (s.size() < 1);
		int n = s.size();
		bool b = false;
		for (int j = n - 1; j >= 0; j--) {
			if (isdigit(s[j])) {
				if (s[j] == '9') {
					break;
				}
				s[j]++;
				cout << s << endl;
				b = true;
				break;
			}
		}
		bool b1 = false;
		if (!b) {
			for (int j = n - 1; j >= 0; j--) {
				if (s[j] == '9') {
					b1 = true;
					s[j] = '0';
				}
				else if (b1 && !isdigit(s[j])) {
					string ans = s.substr(0, j + 1) + '1' + s.substr(j + 1, n - j - 1);
					cout << ans << endl;
					break;
				}
				else if (b1 && s[j] >= '0' && s[j] <= '8') {
					s[j]++;
					cout << s << endl;
					break;
				}
			}
			if (s[0] == '0') {
				s = '1' + s;
				cout << s << endl;
			}
		}
		if (!b && !b1) {
			cout << s << endl;
		}
	}
	return 0;
}
            
            
            
        