結果

問題 No.539 インクリメント
ユーザー jjjj
提出日時 2017-07-01 00:09:03
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 32,780 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 07:18:26
合計ジャッジ時間 1,106 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,812 KB
testcase_01 AC 10 ms
6,816 KB
testcase_02 AC 40 ms
6,944 KB
testcase_03 AC 34 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::N,i,j,first,last
  character*100001::S=""
  character*10::num='0123456789'
  read *,N
  do i=1,N
     read '(a)',S
     last = scan(S,num,.true.)
     if(last.eq.0) then
        print '(a)', TRIM(S)
        cycle
     end if
     first= verify(S(1:last),num,.true.)
     if(S(first+1:last).eq.REPEAT('9',last-first)) then
        do j=LEN_TRIM(S), last, -1
           S(j+1:j+1) = S(j:j)
        end do
        S(first+1:first+1) = '1'
        S(first+2:last+1)  = REPEAT('0',last-first)
     else
        first = verify(S(1:last),'9',.true.)
        S(first:first)=ACHAR(ICHAR(S(first:first))+1)
        if(first.ne.last) then
           S(first+1:last)=REPEAT('0',last-first)
        end if
     end if
     print '(a)', TRIM(S)
  end do
end program main
0