結果

問題 No.118 門松列(2)
ユーザー jj
提出日時 2016-09-17 00:36:32
言語 Fortran
(gFortran 14.2.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 565 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 32,512 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-17 08:06:13
合計ジャッジ時間 1,234 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::N,dist(1:100),i,j,total,res,res2
  integer*8,allocatable::A(:)
  data dist/100*0/,total/0/
  read *,N
  allocate(A(N))
  read *,A
  do i=1, N
     dist(A(i)) = dist(A(i)) + 1
  end do

  res = N
  do i=1,100
     if(dist(i).eq.0) cycle
     res = res - dist(i)
     res2 = res
     do j=i+1,100
        if(dist(j).eq.0) cycle
        res2 = res2 - dist(j)
        total = total + dist(i)*dist(j)*res2
        total = MOD(total,10**9+7)
        if(res2.eq.0) exit
     end do
  end do
  print '(i0)', total
end program main
0