結果

問題 No.375 立方体のN等分 (1)
ユーザー jjjj
提出日時 2016-08-03 23:07:12
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 1,513 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 33,276 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 15:15:44
合計ジャッジ時間 1,516 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 6 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 6 ms
5,376 KB
testcase_27 AC 7 ms
5,376 KB
testcase_28 AC 6 ms
5,376 KB
testcase_29 AC 6 ms
5,376 KB
testcase_30 AC 6 ms
5,376 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 AC 6 ms
5,376 KB
testcase_33 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

subroutine sub(num,insuu,beki)
  implicit none
  integer*8::num,beki,tmp
  integer*8,intent(in)::insuu
  beki = 1
  tmp = insuu
  do while(MOD(num,tmp).eq.0)
     beki = beki + 1
     tmp = tmp * insuu
  end do

  num = num*insuu/tmp
  beki = beki-1
  return
end subroutine sub

subroutine bunkai(N, vinsuu, vbeki)
  integer*8::N,i,j,indx,fsr
  integer*8::vinsuu(15),vbeki(15)
  integer*8::num,insuu,beki
  integer*8,allocatable::furui(:)
  fsr = FLOOR(sqrt(REAL(N)))
  allocate(furui(fsr))

  furui  = 0
  indx   = 1
  num = N
  do i=2, fsr
     if(furui(i).eq.1) cycle
     if(MOD(num,i).ne.0) cycle
     insuu = i
     call sub(num,insuu,beki)
     vinsuu(indx) = insuu
     vbeki (indx) = beki
     indx = indx + 1
     if(num.eq.1) exit
     do j=i+i,MIN(i*i,fsr),i
        furui(j) = 1
     end do
  end do
  if(num.ne.1) then
     vinsuu(indx) = num
     vbeki(indx)  = 1
  end if
end subroutine bunkai

program main
  implicit none
  integer*8::N,i,j
  integer,parameter::limit=15
  integer*8::vinsuu(limit),vbeki(limit)
  integer*8::a,b,c,minimum
  data vinsuu/limit*0/,vbeki/limit*0/
  data a,b,c/3*1/

  read *,N
  call bunkai(N,vinsuu, vbeki)

  do i = 15,1,-1
     if(vinsuu(i).eq.0) cycle
     do j=1,vbeki(i)
        minimum = MIN(a,(MIN(b,c)))
        if(minimum.eq.a) then
           a = a * vinsuu(i)
        else if(minimum.eq.b) then
           b = b * vinsuu(i)
        else
           c = c * vinsuu(i)
        end if
     end do
  end do
  print '(i0," ",i0)', a+b+c-3,N-1
end program main
0