結果
問題 | No.539 インクリメント |
ユーザー |
|
提出日時 | 2020-05-29 19:27:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 1,054 bytes |
コンパイル時間 | 807 ms |
コンパイル使用メモリ | 69,120 KB |
最終ジャッジ日時 | 2025-01-10 16:16:59 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include <iostream>#include <string>void solve() {std::string s;std::getline(std::cin, s);std::string tmp, t;while (!s.empty() && !std::isdigit(s.back())) {tmp.push_back(s.back());s.pop_back();}while (!s.empty() && std::isdigit(s.back())) {t.push_back(s.back());s.pop_back();}if (!t.empty()) {int carry = 1;for (auto& c : t) {c += carry;carry = 0;if (c > '9') {c = '0';carry = 1;}}if (carry) t.push_back('1');}while (!t.empty()) {s.push_back(t.back());t.pop_back();}while (!tmp.empty()) {s.push_back(tmp.back());tmp.pop_back();}std::cout << s << "\n";}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);int q;std::cin >> q;{std::string tmp;std::getline(std::cin, tmp);}while (q--) solve();return 0;}