結果

問題 No.539 インクリメント
ユーザー Hoget157Hoget157
提出日時 2017-06-30 22:56:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 75,288 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 06:52:20
合計ジャッジ時間 1,695 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0