結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-20 12:45:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,496 bytes |
| コンパイル時間 | 827 ms |
| コンパイル使用メモリ | 69,332 KB |
| 実行使用メモリ | 14,336 KB |
| 最終ジャッジ日時 | 2024-11-26 03:19:42 |
| 合計ジャッジ時間 | 10,955 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 3 |
ソースコード
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
class Number
{
public:
string number;
Number(){}
Number(string num)
{
number = num;
}
Number& operator++()
{
size_t length = number.size();
for (int i = length - 1; i >= 0; --i)
{
number[i] = ((number[i] - '0') + 1) % 10 + '0';
if (number[i] != '0') break;
else if (i == 0) {
number = "1" + number;
}
}
return *this;
}
};
int main()
{
int T;
cin >> T;
string line;
getline(cin, line);
while(T--)
{
getline(cin, line);
string head = "";
string num = "";
string tail = "";
bool begin = false;
bool end = false;
for(int i = line.length() - 1; i >= 0; --i)
{
if (end)
{
head = line[i] + head;
continue;
}
if (line[i] >= '0' && line[i] <= '9')
{
begin = true;
num = line[i] + num;
}
else
{
if (!begin)
{
tail = line[i] + tail;
continue;
}
end = true;
head = line[i] + head;
}
}
Number number(num);
++number;
cout << head << number.number << tail << endl;
}
}