結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
hiyokko2
|
| 提出日時 | 2017-06-30 23:08:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 1,510 bytes |
| コンパイル時間 | 1,325 ms |
| コンパイル使用メモリ | 162,016 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-04 21:14:40 |
| 合計ジャッジ時間 | 1,935 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;
signed main()
{
int T;
string S;
cin >> T;
cin.ignore();
REP(i,T) {
//cin >> S;
getline(cin, S);
reverse(S.begin(), S.end());
bool hit = false;
REP(j,S.length()) {
if ('0' <= S[j] && S[j] <= '8') {
S[j] += 1;
reverse(S.begin(), S.end());
cout << S << endl;
hit = true;
break;
} else if (S[j] == '9') {
//cout << "AAAAAa" << endl;
while (S[j] == '9') {
S[j] = '0';
j++;
}
//cout <<"TEST" << S << endl;
if ('0' <= S[j] && S[j] <= '8') {
S[j]++;
reverse(S.begin(), S.end());
cout << S << endl;
hit = true;
break;
} else {
string ans = S.substr(0, j) + '1' + S.substr(j);
reverse(ans.begin(), ans.end());
cout << ans << endl;
hit = true;
break;
}
}
}
if (!hit) {
reverse(S.begin(), S.end());
cout << S << endl;
}
}
}
hiyokko2