zoukankan      html  css  js  c++  java
  • 17: 折纸问题

    17 折纸问题

    作者: 朱星垠 时间限制: 1S 章节: 循环

    问题描述 :
    已知有一张纸,其厚度为1厘米。现在给你一座山的高度N(单位:米)。问将纸对折多少次后,其厚度将超过这座山的高度?

    输入说明 :
    你的程序需要从标准输入设备(通常为键盘)中读入多组测试数据。每组输入数据由一行组成,每行为一个正整数N,N小于等于珠穆朗玛峰的高度。

    输出说明 :
    对每组测试数据,你的程序需要向标准输出文件(通常为启动该程序的文本终端)依次输出一组对应的答案:对折的次数,所有数据前后没有多余的空行,两组数据之间也没有多余的空行。

    输入范例 :
    1
    200
    8848
    输出范例 :
    7
    15
    20
    代码:

    #include <stdio.h>
    #include <math.h>
    int main()
    {
    	double  h, n;
    	while (scanf("%lf", &h) != EOF)
    	{
    		h *= 100;
    		n = log(h) / log(2.0);
    		printf("%d
    ", (int)n+1);
    	}
    	return 0;
    }
    
    Yesterday is history,tomorrow ismystery,but today is a gift!That why it is called Present!
  • 相关阅读:
    单点登录实现机制
    简单工厂
    单例模式
    Remoting
    Redis编码问题
    减少手机页面跳转的方法(转)
    失血模型,充血模型
    Hashtable
    Why we don’t recommend using List<T> in public APIs
    Aggregate累加器
  • 原文地址:https://www.cnblogs.com/VictorierJwr/p/12246163.html
Copyright © 2011-2022 走看看