結果
問題 | No.539 インクリメント |
ユーザー |
![]() |
提出日時 | 2017-06-30 23:44:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 535 bytes |
コンパイル時間 | 1,312 ms |
コンパイル使用メモリ | 167,124 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-04 21:47:21 |
合計ジャッジ時間 | 2,301 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <bits/stdc++.h>using namespace std;void solve() {string s;getline(cin, s);reverse(s.begin(), s.end());bool f = false;for (int i = 0; i < s.size(); i++) {if (isdigit(s[i])) {if (s[i] == '9') {s[i] = '0';f = true;} else {s[i]++;f = false;break;}} else if (f) {s.insert(i, "1");f = false;break;}}if (f) s += "1";reverse(s.begin(), s.end());cout << s << endl;}int main() {int T;cin >> T;cin.ignore();while (T--) {solve();}}