結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
rankBBNT
|
| 提出日時 | 2017-07-04 23:45:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,028 bytes |
| コンパイル時間 | 536 ms |
| コンパイル使用メモリ | 54,748 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-05 16:21:56 |
| 合計ジャッジ時間 | 1,430 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 1 RE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:20: warning: format not a string literal and no format arguments [-Wformat-security]
21 | printf(s);
| ^
main.cpp:27:20: warning: format not a string literal and no format arguments [-Wformat-security]
27 | printf(s);
| ^
main.cpp:39:24: warning: format not a string literal and no format arguments [-Wformat-security]
39 | printf(s);
| ^
main.cpp:9:10: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | fgets(s, 100002, stdin);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘char* fgets(char*, int, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | fgets(s, 100002, stdin);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
using namespace std;
int main(void) {
char s[100000+3];
fgets(s, 100002, stdin);
int T = atoi(s);
for (int i=0; i<T; i++) {
fgets(s, 100002, stdin);
int len = strlen(s);
int dpos;
for (dpos=len-1; dpos>=0; dpos--) {
if (isdigit(s[dpos])) break;
}
if (dpos==-1) {
printf(s);
continue;
}
if (s[dpos]!='9') {
s[dpos]++;
printf(s);
continue;
}
while (s[dpos]=='9') {
s[dpos] = '0';
if (dpos==0 || !isdigit(s[dpos-1])) {
for (int j = 0; j<dpos; j++) fputc(s[j], stdout);
fputc('1', stdout);
for (int j=dpos; j<len; j++) fputc(s[j], stdout);
} else if (s[dpos-1]!='9') {
s[dpos-1]++;
printf(s);
}
dpos--;
}
}
}
rankBBNT