题目:计算1/(2^n)的值的前4为有效数字以及位数。

分析:数论,大整数。直接用数组模拟就可以。

说明:打表计算。查询输出。

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath> using namespace std; double val[1000005];
int bit[1000005]; int main()
{
val[0] = 1;bit[0] = 0;
for (int i = 1 ; i < 1000001 ; ++ i) {
val[i] = val[i-1]/2;
bit[i] = bit[i-1];
if (val[i] < 1) {
val[i] *= 10;
bit[i] --;
}
} int n;
while (~scanf("%d",&n))
printf("2^-%d = %.3lfe%d\n",n,val[n],bit[n]); return 0;
}

UVa 474 - Heads / Tails Probability的更多相关文章

  1. atcoderI - Coins ( 概率DP)

    I - Coins Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement Let NN b ...

  2. [TypeScript] 1. Catching JavaScript Mistakes with TypeScript

    The TypeScript compiler is a powerful tool which catches mistakes even in vanilla JavaScript. Try it ...

  3. [Swust OJ 795]--Penney Game

    题目链接:http://acm.swust.edu.cn/problem/795/ Time limit(ms): 1000 Memory limit(kb): 65535   Description ...

  4. python编程快速上手之第10章实践项目参考答案

      本章主要讲了python程序的调试,当程序有BUG或异常的时候,我们如何调试代码找出问题点.其实在本章之前的章节我们做练习的时候都会遇到各种各样的错语和异常,最初当不知道程序哪里出错的情况下不可否 ...

  5. iOS - Swift Enumerations or how to annoy Tom

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  6. dice2win早期版本

    原理; https://medium.com/dapppub/fairdicedesign-315a4e253ad6 早期版本地址: https://etherscan.io/address/0xD1 ...

  7. [Swift] 随机数 | Random numbers

    ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...

  8. Introduction to Writing Functions in R

    目录 在R中编写函数 args(函数名) 创建一个函数的步骤 1.default args Passing arguments between functions Checking arguments ...

  9. 概率论 --- Uva 11181 Probability|Given

    Uva 11181 Probability|Given Problem's Link:   http://acm.hust.edu.cn/vjudge/problem/viewProblem.acti ...

随机推荐

  1. 高斯拉普拉斯算子(Laplace of Gaussian)

    高斯拉普拉斯(Laplace of Gaussian) kezunhai@gmail.com http://blog.csdn.net/kezunhai Laplace算子作为一种优秀的边缘检测算子, ...

  2. IT忍者神龟之Oracle DBA经常使用查询吐血列举

    –1. 查询系统全部对象 select owner, object_name, object_type, created, last_ddl_time, timestamp, status from ...

  3. Controller@实现Controller的两种形式

    实现Controller的两种形式 形式1:仅仅实现IController接口,自定义Controller对Request的实现.形式2:在实现IController接口以后,继承Controller ...

  4. transition与animation

    以前,一直都知道,transition是animation的一个简化版,甚至不算是动画,而是一种过渡. transition的用法 早两天用transition写了一个按钮滑动的效果,类似于IOS的设 ...

  5. 教师简介 (Alma Del Tango的小站)

    教师简介 (Alma Del Tango的小站) Esteban Peng (TT) & Emilia Jia (Amy) TT和Amy是北京极具影响力的专业舞者,他们从07年开始推广阿根廷探 ...

  6. 遍历关联数组 index by varchar2

    --字符串序列要这样 declare     type t   is table of number(3) index by varchar2(3);    hash_t t;      l_row ...

  7. VB.net数据库编程(03):一个SQLserver连接查询的简单样例

    这个样例,因为在ADO.net入门已经专门学了,再次进行复习 一下. 主要掌握连接字串的情况. 过程就是: 1.引用System.Data.SqlClient.而Access中引用 的是System. ...

  8. android录音功能的实现

    这个录音实现是我在Bus上看到并下载的,他那个源码不完整,再次把我整理完整的代码贴出,源码地址在这:http://download.csdn.net/detail/chaozhung/5618649 ...

  9. Eclipse更改默认工作目录的方法

    参考: Eclipse更改默认工作目录的方法:http://blog.163.com/take_make/blog/static/208212210201272611406227/ 用记事本打开&qu ...

  10. http权威指南 telnet

    对于winXP 1.先启动一个telnet程序连接到TCP服务器中. telnet www.joes-hardware.com 80 2.在连接上的TCP服务器的telnet程序窗口中同时按下 &qu ...