結果
| 問題 |
No.539 インクリメント
|
| コンテスト | |
| ユーザー |
LayCurse
|
| 提出日時 | 2016-01-11 07:08:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 758 bytes |
| コンパイル時間 | 1,111 ms |
| コンパイル使用メモリ | 157,616 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 06:06:26 |
| 合計ジャッジ時間 | 2,572 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:7: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
13 | gets(buf);
| ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
from /usr/include/c++/11/cstdio:42,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:46,
from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
240 | gets (char *__str)
| ^~~~
main.cpp:16:9: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
16 | gets(buf);
| ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
from /usr/include/c++/11/cstdio:42,
from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:46,
from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
240 | gets (char *__str)
| ^~~~
main.cpp:13:7: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | gets(buf);
| ~~~~^~~~~
main.cpp:16:9: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | gets(buf);
| ~~~~^~~~~
/usr/bin/ld: /tmp/ccFp1Yey.o: in function `main':
main.cpp:(.text.startup+0x22): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int T, N;
char buf[100010];
int main(){
int i, j, k;
gets(buf);
T = atoi(buf);
while(T--){
gets(buf);
N = strlen(buf);
for(i=N-1;i>=0;i--) if('0'<=buf[i]&&buf[i]<='9') break;
if(i==-1){ puts(buf); continue; }
j = i;
while(i-1 >= 0 && '0'<=buf[i-1]&&buf[i-1]<='9') i--;
REP(k,i,j+1) if(buf[k] != '9') break;
if(k==j+1){
N++;
buf[N] = '\0';
for(k=N-1;k>j+1;k--) buf[k] = buf[k-1];
buf[i] = '1';
REP(k,i+1,j+2) buf[k] = '0';
} else {
for(k=j;k>=i;k--){
if(buf[k]!='9'){ buf[k]++; break; }
buf[k] = '0';
}
}
puts(buf);
}
return 0;
}
LayCurse