結果
問題 | No.539 インクリメント |
ユーザー | 193s |
提出日時 | 2017-06-30 22:51:10 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,260 bytes |
コンパイル時間 | 771 ms |
コンパイル使用メモリ | 84,412 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-15 06:50:05 |
合計ジャッジ時間 | 1,346 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 5 ms
6,940 KB |
testcase_03 | WA | - |
ソースコード
#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; }