!> 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