結果
| 問題 |
No.278 連続する整数の和(2)
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-08-31 23:13:52 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,008 bytes |
| コンパイル時間 | 1,738 ms |
| コンパイル使用メモリ | 32,640 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-14 13:39:39 |
| 合計ジャッジ時間 | 2,667 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 3 |
ソースコード
program main
implicit none
integer*8::C,N,i,j,ABGCD
read *,N
if(MOD(N,2).eq.0) then
ABGCD = gcd(2*N,1+N)
N = N/2
else
ABGCD = gcd(N,(1+N)/2)
end if
C = 1
call sub(ABGCD,C)
call sub(N,C)
print '(i0)',C
contains
subroutine sub(N,c)
integer*8,intent(inout)::N,C
integer*8::i,j,SQRTN
integer*1,allocatable::insuu(:)
SQRTN =INT(SQRT(DBLE(N)))
allocate(insuu(SQRTN))
insuu = 0
do i=2,SQRTN
if(insuu(i).eq.1) continue
do j=i+i,SQRTN,i
insuu(j) = 1
end do
if(MOD(N,i).eq.0) then
do
C = (i+1)*C
N = N/i
if(MOD(N,i).ne.0) exit
end do
end if
if(N.eq.1) exit
end do
if(N.ne.1) C = C*(1+N)
deallocate(insuu)
end subroutine sub
recursive function gcd(a,b) result(c)
implicit none
integer*8::a,b,c
if(b.eq.0) then
c = a
else
c = gcd(b,MOD(a,b))
end if
end function gcd
end program main
jj