結果

問題 No.36 素数が嫌い!
ユーザー jjjj
提出日時 2016-10-10 17:16:45
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 1,327 bytes
コンパイル時間 1,138 ms
コンパイル使用メモリ 29,160 KB
実行使用メモリ 77,808 KB
最終ジャッジ日時 2023-09-09 07:41:52
合計ジャッジ時間 3,286 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
37,520 KB
testcase_01 AC 24 ms
61,084 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 42 ms
26,936 KB
testcase_12 AC 127 ms
77,808 KB
testcase_13 AC 125 ms
77,684 KB
testcase_14 AC 16 ms
49,264 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 14 ms
31,832 KB
testcase_20 AC 34 ms
77,684 KB
testcase_21 AC 31 ms
60,004 KB
testcase_22 AC 25 ms
61,680 KB
testcase_23 AC 17 ms
38,036 KB
testcase_24 AC 31 ms
41,976 KB
testcase_25 AC 18 ms
41,340 KB
testcase_26 AC 62 ms
48,152 KB
testcase_27 AC 108 ms
67,212 KB
testcase_28 AC 61 ms
47,168 KB
testcase_29 AC 120 ms
75,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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"
          else
             print '(a)',"NO"
          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
0