题目:计算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. Ubuntu下ssh免password登录安装

    1.首先在本机安装openssh-server和openssh-client. 命令:sudo apt-get install openssh-server openssh-client 2.在检查当 ...

  2. 基于visual Studio2013解决C语言竞赛题之1013字符串查找

         题目 解决代码及点评 /* 功能:编写函数IND,让它判断一个字符串是否为另一个字符串的子串的功能,若是则返回第一次出现的起始位置,否则返回0 时间:13:55 2013 ...

  3. 挺苹果的声音,iPhone 5s的两处进步

    苹果iPhone 5s发布后的两处重大进步让我很关注,但看了网上众多网友的点评,又深深的被中国当前手机发烧友圈的这种屌丝文化所震撼,这不是一条正确的道路,这将把中国的手机产业引向歧途,所以我不得不说几 ...

  4. C语言声明解析方法

    1.C语言声明的单独语法成份     声明器是C语言声明的非常重要成份,他是所有声明的核心内容,简单的说:声明器就是标识符以及与它组合在一起的任何指针.函数括号.数组下表等,为了方便起见这里进行分类表 ...

  5. pthread_setschedprio()函数详解!!!

    pthread_setschedprio() Set a thread's priority 用于设置现成的优先级 包含在头文件 #include <pthread.h> 用法:int p ...

  6. 重载new delete操作符是怎么调用的

    自定义的new操作符是怎么对英语new 一个对象的?自定义的delete操作符什么情况下得到调用?new一个对象时出现异常需要我操心内存泄露吗?下面的一个例子帮我们解开所有的疑惑. 1. 调用规则   ...

  7. 499 - What's The Frequency, Kenneth?

     What's The Frequency, Kenneth?  #include <stdio.h> main() { int i; char *suffix[]= { "st ...

  8. 【app】遍历目录所有文件

    遍历目录所有文件   原创,转载时请注明,谢谢.邮箱:tangzhongp@163.com 博客园地址:http://www.cnblogs.com/embedded-tzp Csdn博客地址:htt ...

  9. 大数据实时处理-基于Spark的大数据实时处理及应用技术培训

    随着互联网.移动互联网和物联网的发展,我们已经切实地迎来了一个大数据 的时代.大数据是指无法在一定时间内用常规软件工具对其内容进行抓取.管理和处理的数据集合,对大数据的分析已经成为一个非常重要且紧迫的 ...

  10. 基于visual Studio2013解决面试题之0209最大堆排序

     题目