結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
CELICA
|
| 提出日時 | 2020-09-17 08:31:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 915 bytes |
| コンパイル時間 | 1,803 ms |
| コンパイル使用メモリ | 172,232 KB |
| 実行使用メモリ | 9,372 KB |
| 最終ジャッジ日時 | 2024-06-22 06:23:55 |
| 合計ジャッジ時間 | 3,269 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
const string TARGET_NO = "0539";
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
cin.ignore();
vector<string> vs(t);
for (auto&& it : vs)
getline(cin, it);
stringstream ss;
for (auto&& v : vs)
{
bool f{ false };
char carry{ 1 };
auto it = v.rbegin();
while (carry && it != v.rend())
{
if (*it >= '0' && *it <= '8')
{
++(*it);
f = true;
carry = 0;
}
else if (*it == '9')
{
*it = '0';
if (it + 1 == v.rend())
{
v = "1" + v;
break;
}
else
f = true;
}
else
{
if (f)
{
v.insert(v.rend() - it, string("1"));
break;
}
}
++it;
}
ss << v << "\n";
}
cout << ss.str();
return 0;
}
CELICA