結果

問題 No.2939 Sigma Popcount Problem
ユーザー osada-yum
提出日時 2024-11-10 01:53:18
言語 Fortran
(gFortran 14.2.0)
結果
WA  
実行時間 -
コード長 951 bytes
コンパイル時間 1,798 ms
コンパイル使用メモリ 31,488 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-10 01:53:23
合計ジャッジ時間 4,513 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

!> This file was processed by `fypp`.
!> Today's fortune: "Bad;)", really OK?
!> ランダムウォーク猿「'両側から見る' で はっぴー.」
!> ギャンブラー猿「...」
program f902939
  use, intrinsic :: iso_fortran_env
  !> auto use module
  implicit none
  integer(int32) :: t
  integer(int32) :: i
  read(input_unit, *) t
  do i = 1, t
     call solve()
  end do
contains
  impure subroutine solve()
    integer(int32), parameter :: maxi_b = 40
    integer(int64) :: n
    integer(int64) :: ans
    integer(int32) :: i
    read(input_unit, *) n
    ans = 0_int64
    do i = 0, maxi_b
       ! write(error_unit, *) i, ans
       if (n - ishft(1_int64, i) <= 0_int64) exit
       ans = ans + &
            & ishft(1_int64, i) * (n / ishft(1_int64, i + 1)) + &
            & max(0_int64, mod(n, ishft(1_int64, i + 1)) - ishft(1_int64, i) + 1)
    end do
    write(output_unit, '(i0)') ans
  end subroutine solve
end program f902939
0