結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2017-06-30 22:40:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 815 bytes |
| コンパイル時間 | 580 ms |
| コンパイル使用メモリ | 67,616 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-04 20:38:37 |
| 合計ジャッジ時間 | 1,507 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
using namespace std;
int main()
{
int n; cin >> n;
cin.ignore();
for (int i = 0; i < n; i++) {
string s; getline(cin, s);
bool up = false;
for (int j = s.size() - 1; j >= 0; j--) {
if (up) {
if (s[j] >= '0' && s[j] < '9') {
s[j]++;
up = false;
break;
}
else if(s[j] == '9'){
s[j] = '0';
up = true;
}
else {
s.insert(s.begin()+j+1,'1');
up = false;
break;
}
}
else {
if (s[j] >= '0' && s[j] < '9') {
s[j]++;
up = false;
break;
}
else if (s[j] == '9') {
s[j] = '0';
up = true;
}
}
}
if (up)s.insert(s.begin(), '1');
cout << s << endl;
}
return 0;
}
kurenai3110