HBC15816Various Tree题解

北笙凉宸 算法基础篇 50 0
想要检验自己的编程水平?来试试全网最全C++题库,让您在挑战中不断进步。
It’s universally acknowledged that there’re innumerable trees in the campus of HUST. And there are many different types of trees in HUST, each of which has a number represent its type. The doctors of biology in HUST find 4 different ways to change the tree’s type x into a new type y: 1. y=x+1 2. y=x-1 3. y=x+f 4. y=x-f The function f is defined as the number of 1 in x in binary representation. For example, f=1, f=1, f=2, f=2. Now the doctors are given a tree of the type A. The doctors want to change its type into B. Because each step will cost a huge amount of money, you need to help them figure out the minimum steps to change the type of the tree into B. Remember the type number should always be a natural number .

It’s universally acknowledged that there’re innumerable trees in the campus of HUST. And there are many different types of trees in HUST, each of which has a number represent its type. The doctors of biology in HUST find 4 different ways to change the tree’s type x into a new type y: 1.    y=x+1 2.    y=x-1 3.    y=x+f(x) 4.    y=x-f(x) The function f(x) is defined as the number of 1 in x in binary representation. For example, f(1)=1, f(2)=1, f(3)=2, f(10)=2. Now the doctors are given a tree of the type A. The doctors want to change its type into B. Because each step will cost a huge amount of money, you need to help them figure out the minimum steps to change the type of the tree into B.  Remember the type number should always be a natural number (0 included).

HBC15816Various Tree题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
成为编程大师,不再是梦想!全网最全C++题库,助您开启编程新篇章。

标签: HBC15816Various Tree题解