結果

問題 No.300 平方数
ユーザー jjjj
提出日時 2016-09-19 03:19:05
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 1,050 bytes
コンパイル時間 1,941 ms
コンパイル使用メモリ 33,996 KB
実行使用メモリ 10,120 KB
最終ジャッジ日時 2024-04-28 15:44:35
合計ジャッジ時間 3,178 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 3 ms
7,528 KB
testcase_03 AC 1 ms
6,948 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 12 ms
10,048 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 4 ms
6,940 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 3 ms
10,120 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 4 ms
10,072 KB
testcase_22 AC 5 ms
9,188 KB
testcase_23 AC 6 ms
8,816 KB
testcase_24 AC 5 ms
6,944 KB
testcase_25 AC 10 ms
8,632 KB
testcase_26 AC 7 ms
7,984 KB
testcase_27 AC 5 ms
6,940 KB
testcase_28 AC 10 ms
8,688 KB
testcase_29 AC 7 ms
9,432 KB
testcase_30 AC 7 ms
9,496 KB
testcase_31 AC 8 ms
9,864 KB
testcase_32 AC 8 ms
6,944 KB
testcase_33 AC 5 ms
6,944 KB
testcase_34 AC 10 ms
9,168 KB
testcase_35 AC 8 ms
6,944 KB
testcase_36 AC 6 ms
7,612 KB
testcase_37 AC 5 ms
6,944 KB
testcase_38 AC 3 ms
7,468 KB
testcase_39 AC 7 ms
8,232 KB
testcase_40 AC 6 ms
7,328 KB
testcase_41 AC 4 ms
6,948 KB
testcase_42 AC 3 ms
6,940 KB
testcase_43 AC 7 ms
9,288 KB
testcase_44 AC 6 ms
7,792 KB
testcase_45 AC 5 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::X,Y,upper,i
  integer*8,allocatable::base(:),exponents(:)
  read *,X
  upper = DINT(log(DBLE(X)))+1_8
  allocate(base(upper),exponents(upper))
  base = 0
  exponents = 0
  call factorization(X, base, exponents)

  Y = 1
  do i=1,size(base)
     if(MOD(exponents(i),2).ne.0) Y = Y * base(i)
  end do

  print '(i0)', Y
contains
  subroutine factorization(n, base, exponents)
    integer*8::n,base(:),exponents(:)
    integer*8::i,j,itr,upper
    integer*8,allocatable::furui(:)
    data itr/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
       if(n.eq.1) return
    end do
    itr = itr + 1
    base(itr) = n
    exponents(itr) = 1
  end subroutine factorization
end program main
0