結果
問題 | No.539 インクリメント |
ユーザー |
![]() |
提出日時 | 2017-06-30 23:03:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 1,874 bytes |
コンパイル時間 | 1,411 ms |
コンパイル使用メモリ | 171,044 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 21:06:39 |
合計ジャッジ時間 | 2,400 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 3 |
ソースコード
#include<bits/stdc++.h>#define rep(i,a,b) for(int i=a;i<b;i++)#pragma GCC optimize ("-O3")using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }//---------------------------------------------------------------------------------------------------/*---------------------------------------------------------------------------------------------------∧_∧∧_∧ (´<_` ) Welcome to My Coding Space!( ´_ゝ`) / ⌒i/ \ | |/ / ̄ ̄ ̄ ̄/ |__(__ニつ/ _/ .| .|____\/____/ (u ⊃---------------------------------------------------------------------------------------------------*/string S;string incriment(string s) {int d = 1;int n = s.length();rep(i, 0, n) {int c = s[n - 1 - i] - '0' + d;d = c / 10;c = c % 10;s[n - 1 - i] = char('0' + c);}if (0 < d) s = char('0' + d) + s;return s;}void solve() {getline(cin, S);pair<int, int> p = {-1, -1};rep(L, 0, S.length()) if('0' <= S[L] && S[L] <= '9') {int R = L + 1;while ('0' <= S[R] && S[R] <= '9') R++;p = { L, R - 1 };L = R - 1;}if (p.first < 0) {printf("%s\n", S.c_str());return;}string A = S.substr(0, p.first);string B = S.substr(p.first, p.second - p.first + 1);string C = S.substr(p.second + 1);B = incriment(B);printf("%s%s%s\n", A.c_str(), B.c_str(), C.c_str());}//---------------------------------------------------------------------------------------------------void _main() {int T; cin >> T;string S; getline(cin, S);rep(i, 0, T) solve();}