結果

問題 No.539 インクリメント
ユーザー @abcde
提出日時 2019-06-16 04:10:38
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 1,210 ms
コンパイル使用メモリ 157,816 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-21 20:18:17
合計ジャッジ時間 1,941 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:9: 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:3:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
main.cpp:16:13: 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:3:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
main.cpp:13:9: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     gets(buf);
      |     ~~~~^~~~~
main.cpp:16:13: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         gets(buf);
      |         ~~~~^~~~~
/usr/bin/ld: /tmp/ccSol97a.o: in function `main':
main.cpp:(.text.startup+0x22): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #
プレゼンテーションモードにする

// .
// ※.
#include<bits/stdc++.h>
using namespace std;
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--;
for(k = i; k < j + 1; k++) 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';
for(k = i + 1; k < j + 2; k++) buf[k] = '0';
}else{
for(k = j; k >= i; k--){
if(buf[k] != '9'){ buf[k]++; break; }
buf[k] = '0';
}
}
puts(buf);
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0