program yukicoder_2426 use, intrinsic :: iso_fortran_env implicit none integer(int32), parameter :: max_len = 10000 integer(int64) :: n, m character(len=:), allocatable :: operations integer(int32) :: k read(input_unit, *) n allocate(character(len=max_len) :: operations) operations(1:max_len) = "" m = n do k = 1, max_len if (m == 1) exit if (iand(m, b'1') == 0) then m = m / 2 operations(k:k) = "/" else !> b is odd. if (iand((3 * m + 1) / 2, b'1') == 0) then m = 3 * m + 1 operations(k:k) = "+" else !> iand((3 * m - 1) / 2, b'1') == 0 m = 3 * m - 1 operations(k:k) = "-" end if end if end do write(output_unit, '(i0)') k write(output_unit, '(a)') trim(operations) end program yukicoder_2426