Logo
(追記) (追記ここまで)

18004번 - From A to B 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 512 MB52229225156.027%

문제

You are given two integers, a and b. You want to transform a into b by performing a sequence of operations. You can only perform the following operations:

  • Divide a by two (but only if a is even)
  • Add one to a

What is the minimum number of operations you need to transform a into b?

입력

The single line of input contains two space-separated integers a and b (1 ≤ a, b ≤ 109)

출력

Output a single integer, which is the minimum number of the given operations needed to transform a into b.

제한

예제 입력 1

103 27

예제 출력 1

4

예제 입력 2

3 8

예제 출력 2

5

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2019 Southeast USA Regional Programming Contest > Division 2 D번

ICPC > Regionals > North America > Pacific Northwest Regional > 2019 ICPC Pacific Northwest Region > Division 1 D번

ICPC > Regionals > North America > Pacific Northwest Regional > 2019 ICPC Pacific Northwest Region > Division 2 Q번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /