結果
| 問題 | 
                            No.36 素数が嫌い!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             jj
                         | 
                    
| 提出日時 | 2016-10-10 17:15:40 | 
| 言語 | Fortran  (gFortran 14.2.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,302 bytes | 
| コンパイル時間 | 314 ms | 
| コンパイル使用メモリ | 34,204 KB | 
| 実行使用メモリ | 77,824 KB | 
| 最終ジャッジ日時 | 2024-11-22 00:52:39 | 
| 合計ジャッジ時間 | 2,438 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 24 WA * 2 | 
ソースコード
program main
  implicit none
  integer*8::N,upper,i
  integer*8,allocatable::base(:),exponents(:)
  read *,N
  upper = DINT(log(DBLE(N)))+1_8
  allocate(base(upper),exponents(upper))
  base = 0
  exponents = 0
  call factorization(N, base, exponents)
contains
  subroutine factorization(n, base, exponents)
    integer*8::n,base(:),exponents(:)
    integer*8::i,j,itr,upper,total_exponents
    integer*8,allocatable::furui(:)
    data itr/0/, total_exponents/0/
    upper = INT(SQRT(DBLE(n)+1))
    allocate(furui(2:upper))
    furui = 0
    do i=2,upper
       if(furui(i).ne.0) cycle
       if(MOD(n, i).ne.0) cycle
       itr = itr + 1
       base(itr) = i
       do j=i+i,upper,i
          furui(j) = 1
       end do
       do j=1,upper
          n = n/i
          if(MOD(n,i).ne.0) exit
       end do
       exponents(itr) = j
       total_exponents = total_exponents + j
       if(n.ne.1) then
          if(total_exponents.ge.2) then
             print '(a)',"YES"
             return
          end if
       else
          if(total_exponents.ge.3) then
             print '(a)',"YES"
             return
          end if
          return
       end if
    end do
    itr = itr + 1
    base(itr) = n
    exponents(itr) = 1
    print '(a)', "NO"
  end subroutine factorization
end program main
            
            
            
        
            
jj