結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
rankBBNT
|
| 提出日時 | 2017-07-04 22:37:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 904 bytes |
| コンパイル時間 | 430 ms |
| コンパイル使用メモリ | 58,496 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-05 16:18:34 |
| 合計ジャッジ時間 | 1,320 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 3 |
ソースコード
#include <iostream>
#include <string>
#include <stdio.h>
#include <ctype.h>
using namespace std;
int main(void){
int T;
cin >> T;
for (int i=0; i<=T; i++) {
string s;
std::getline(cin, s);
int dpos;
for (dpos=s.length()-1; dpos>=0; dpos--) {
if (isdigit(s[dpos])) break;
}
if (dpos==-1) {
cout << s << endl;
continue;
}
if (s[dpos]!='9') {
s[dpos]++;
cout << s << endl;
continue;
}
while (s[dpos]=='9') {
s[dpos] = '0';
if (dpos==0 || !isdigit(s[dpos-1])) {
cout << s.substr(0, dpos) << "1" << s.substr(dpos) << endl;
} else if (s[dpos-1]!='9') {
s[dpos-1]++;
cout << s << endl;
}
dpos--;
}
}
}
rankBBNT