結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2017-07-08 14:28:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 43 ms / 2,000 ms |
| コード長 | 1,010 bytes |
| コンパイル時間 | 1,439 ms |
| コンパイル使用メモリ | 85,220 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 19:44:31 |
| 合計ジャッジ時間 | 1,986 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 539.cc: No.539 インクリメント - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
/* typedef */
/* global variables */
/* subroutines */
/* main */
int main() {
int tn;
cin >> tn;
while (cin.get() != '\n');
while (tn--) {
string s;
getline(cin, s);
int p = s.size() - 1;
while (p >= 0 && (s[p] < '0' || s[p] > '9')) p--;
if (p < 0) {
puts(s.c_str());
continue;
}
bool co = true;
while (co && p >= 0 && s[p] >= '0' && s[p] <= '9') {
s[p]++;
if (s[p] > '9') s[p] = '0';
else co = false;
p--;
}
if (co) s.insert(p + 1, 1, '1');
puts(s.c_str());
}
return 0;
}
tnakao0123