結果

問題 No.356 円周上を回る3つの動点の一致
ユーザー jjjj
提出日時 2017-01-25 00:18:17
言語 Fortran
(gFortran 14.2.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 596 ms
コンパイル使用メモリ 30,848 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-23 08:08:05
合計ジャッジ時間 2,503 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::x,y,z,a,b,c,d,e,f
  integer*8::i
  read *,x,y,z

  a = x*y
  b = y-x
  c = y*z
  d = z-y
  call lcm_fraction(a,b,c,d,e,f)
  print '(i0,"/",i0)',e,f
contains
  recursive function gcd(a,b) result(c)
    integer*8::a,b,c
    if(b.eq.0) then
       c = a
    else
       c = gcd(b,MOD(a,b))
    end if
  end function gcd
  function lcm(a,b) result(c)
    integer*8,intent(in)::a,b
    integer*8::c
    c = (a*b)/gcd(a,b)
  end function lcm
  subroutine lcm_fraction(a,b,c,d,e,f)
    ! e/f=lcm(a/b,c/d)
    !
    ! l = a/b*X = c/d*Y = lcm(a/b,c/d)
    ! b*d*l = a*d*X = c*b*Y = lcm(a*d, b*c)
    ! l = lcm(a*d, b*c)/(b*d)
    integer*8::a,b,c,d,e,f
    integer*8::adbc,bd,gcd_adbcbd
    adbc = lcm(a*d,b*c)
    bd = b*d
    gcd_adbcbd = gcd(adbc, bd)
    e = adbc/gcd_adbcbd
    f = bd/gcd_adbcbd
  end subroutine lcm_fraction
end program main
0