ソースコード 

Copy
Copy
program main
  implicit none
  integer(8) i, N, lim, m(100), t, ans, exp, level, N1
  !integer(8),allocatable:: A(:,:)
  read(*, *) N
  N1 = N
  lim = 1000000
  !allocate(A(N,2)
  m = 0
  t = 0
  do i = 1,100
    m(i) = t+i
    t = m(i)
  end do
  !read(*, *) (L(i), i = 1,N)
  t = 2
  exp = 0
  level = 0
  ans = 0
  if (N == 1) then
    ans = 0
  else
    do
      if (mod(N,t) == 0) then
        exp = exp + 1
        N = N/t
        if (exp == m(level+1)) then
          level = level + 1
        end if
      else
        ans = ans + level
        exp = 0
        level = 0
        t = t+1
      endif
      if (t > lim) then
        if (N1 > 1) then
          ans = ans + 1
        endif
        exit
      endif
    end do
  endif
  write(*, *) ans
end program main