- public class Shift {
- public static void main(String[] args) {
- //以cm计珠峰高度
- final int everest=884800;
- //纸厚
- int paperThickness=1,
- //折叠次数
- count = 0;
- while(true){
- if(paperThickness>=everest){
- break;
- }
- paperThickness= paperThickness<<1;
- count+=1;
- }
-
- System.out.println("需要折叠"+count+"次才能达到珠峰高度");
- }
- }
复制代码 |