結果

問題 No.537 ユーザーID
ユーザー jj
提出日時 2017-06-30 23:08:06
言語 Fortran
(gFortran 14.2.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,259 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 35,808 KB
実行使用メモリ 18,384 KB
最終ジャッジ日時 2024-10-04 21:13:50
合計ジャッジ時間 1,636 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::i,j
  integer*8::N
  integer*8::a,b,aa,bb
  integer*8::aaa,bbb
  integer*8::total=0,total2=0
  integer*8,allocatable::list(:),listr(:)

  read *,N
  allocate(list(INT(sqrt(real(N))+1)*2))
  list=0
  do i=1,INT(sqrt(real(N)))
     if(MOD(N,i).ne.0) cycle

     a = i
     b = N/i
     aa = a+roundup(a)*b
     bb = a*roundup(b)+b
     total=total+1
     list(total)=aa
     total=total+1
     list(total)=bb
     !     print *,aa,bb
  end do
  allocate(listr(total))
  listr = qsortr(list(1:total))

  total2 = 1
  do i=2,total
     if(listr(i-1).eq.listr(i))cycle
     total2=total2+1
  end do

  print '(i0)', total2
contains
  function roundup(a) result(aa)
    integer*8::a,aa,tmp
    aa = 1
    tmp = a
    do
       aa = aa*10
       tmp = tmp/10
       if(tmp.eq.0) exit
    end do
  end function roundup
  recursive function qsortr(x) result(y)
    integer*8,intent(in) ::x(:)
    integer*8,allocatable::y(:)
    integer*8::pivot,total
    total = size(x)
    if (total <=1) then
       y = x
    else
       pivot = x(total/2)
       y = [qsortr(pack(x, x .gt. pivot)), &
            pack(x, x .eq. pivot),        &
            qsortr(pack(x, x .lt. pivot))]
    endif
  end function qsortr

end program main
0