結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-30 22:51:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,260 bytes |
| コンパイル時間 | 648 ms |
| コンパイル使用メモリ | 83,752 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-04 20:49:48 |
| 合計ジャッジ時間 | 1,428 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 1 WA * 2 |
ソースコード
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
int T;
signed main() {
ios::sync_with_stdio(false); cin.tie(0);
cin >> T;
string s;
getline(cin, s);
rep(_, T) {
getline(cin, s);
int offset = -1;
rep(i, s.length()) {
char c = s[i];
if (c >= '0' && c <= '9') offset = i;
}
if (offset == -1) {
cout << s << "\n";
continue;
}
bool ok = false;
while (offset >= 0 && s[offset] >= '0' && s[offset] <= '9') {
if (s[offset] != '9') {
s[offset]++;
ok = true;
break;
}
s[offset] = '0';
offset--;
}
string o = "";
if (ok) o = s;
else {
rep(i, offset+1) {
o += s[i];
}
o += '1';
for (int i=offset+1; i<=s.length(); i++) o += s[i];
}
cout << o << "\n";
}
return 0;
}