結果
| 問題 | No.539 インクリメント | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-06-30 22:56:02 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 37 ms / 2,000 ms | 
| コード長 | 727 bytes | 
| コンパイル時間 | 661 ms | 
| コンパイル使用メモリ | 75,408 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-04 20:56:45 | 
| 合計ジャッジ時間 | 1,396 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 3 | 
ソースコード
#include <iostream>
#include <map>
#include <cmath>
#define int long long
#define EPS 1e-9
#define INF 1e+9
using namespace std;
signed main() {
	int n;
	string s;
	cin >> n;
	getchar();
	for(int i = 0;i < n;i++){
		getline(cin,s);
		bool flag = false,put = false;
		for(int j = s.length() - 1;j >= -1;j--){
			if(flag && j == -1){
				cout << "1" << s << endl;
				put = true;
			}
			else if(s[j] >= '0' && s[j] <= '8'){
				s[j]++;
				cout << s << endl;
				put = true;
				break;
			}else if(s[j] == '9'){
				flag = true;
				s[j] = '0';
			}else if(flag){
				cout << s.substr(0,j + 1) << 1 << s.substr(j + 1,s.length() - j - 1) << endl;
				put = true;
				break;
			}
		}
		if(!put) cout << s << endl;
	}
	return 0;
}
            
            
            
        