結果
| 問題 |
No.2939 Sigma Popcount Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-10 01:56:29 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 2,000 ms |
| コード長 | 983 bytes |
| コンパイル時間 | 1,317 ms |
| コンパイル使用メモリ | 31,488 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-10 01:56:32 |
| 合計ジャッジ時間 | 3,473 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
!> This file was processed by `fypp`.
!> Today's fortune: "forever WJ...", really OK?
!> ランダムウォーク猿「'シュタイナー木' で はっぴー.」
!> ギャンブラー猿「AtCoder はゲームだ.」
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