Java implementation of the Blue Bridge Cup simulation tree leaf node number

Problem Description
  a tree contains 2019 nodes, the number of leaf nodes contain up?
The answer submitted
  This is a result of fill in the blank questions, you only need to submit to the calculated result. The results of this question is an integer, when submitting answers only to fill in the integer, fill in the extra content will not score.

package 第十三次模拟;

public class Demo3节点 {
	public static void main(String[] args) {
		int start=1;
		int sum=2019;
		while(sum>=0){
			sum-=start;
			start*=2;
//			System.out.println(sum);
		}
		System.out.println(start/2);
		System.out.println(sum);
	}
}

Released 1472 original articles · won praise 10000 + · views 1.76 million +

Guess you like

Origin blog.csdn.net/a1439775520/article/details/104750227