MacaW Baby Learns Computer
Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Description
Problem F
MacaW Baby Learns Computer
The newborn Macaw baby is learning computer now. But as the Macaw dad cannot afford much so he has bought a computer that supports only floating-point data type (No support for integers). But as birds don’t give exams (no CGPA calculation), don’t calculate probability (Ignoring problem-setter birds) and don’t intentionally share food so they rarely do floating-point calculations. Luckily, floating-point numbers can hold many integer values perfectly. Now your job is to convince the Macaw dad how good a floating-point number is in holding integer values. For this problem floating-point numbers (Similar to real world no doubt) are stored in the following way:
Suppose there is a binary number 10112, then to store it in computer as a floating-point number, it is divided into two parts,(a) mantissa(b) exponent. If value of mantissa part is mv, then
. So it is stored as, 0.1011*24 (Assuming there is 4 bits of storage for mantissa). In other words the four bits allocated for mantissa contains 1011 and the exponent part contains the value 4 (In binary of course). As the most significant bit of mantissa is always 1 so it is not even stored at all. So for storing 10112 the mantissa part contains 011 (Ignoring the most siginificantbit 1) and the exponent part contains 100 (Binary equivalent of 4). Given the number of bits allocated for mantissa and exponent, your job is to find out how many different positive integer values can this floating-point number represent. In real life in floating-point number a bit is used for sign of number and another bit is used for sign of exponent. Those two bits are not needed for this problem (As negative integers are not counted and negative exponent never makes a positive integer value)
Input
The input file contains at most1000 lines of input. Each line contains two integers m (1 ≤ m ≤ 60) and e (1 ≤ e ≤ 60) which denotes the number of bits allocated for mantissa and exponent respectively.
A line containing two zeroes terminates the input. This line should not be processed.
Output
For each test case produce one line of output. This line contains an integer which denotes how many different positive integer values this floating-point number can represent. You can assume that the input values will be such that this integer will
not exceed 9*1018.
|
Sample Input |
Output for Sample Input |
|
2 2 3 4 4 3 0 0 |
7 103 63 |
Illustration of the first sample input:
A floating-point number that has two bits for mantissa and two bits for exponent can represent the following values (Not less than 1) 1.000000, 1.250000, 1.500000, 1.750000, 2.000000, 2.500000, 3.000000,
3.500000, 4.000000, 5.000000, 6.000000 and 7.000000. Of these values only 7 values are integers.
Problemsetter: Shahriar Manzoor
Special Thanks: Md. Mahbubul Hasan
/*
记得预处理 还有就是 那么long long 的类型不能 有位移 大于int范围位移就出错了
然后还有 自己也是比较的坑啊 那个 题目看了很久才理解然后就 我为何如此的弱
*/
#include <iostream>
#include <string.h>
#include <cstdio>
using namespace std;
int n,m;
long long ans,L,M,K;
long long N[61];
int main()
{
int n,m,a;
L=1;
for(int i=0;i<=61;i++)
{
N[i]=L;
L=L*2;
}
while(scanf("%d%d",&n,&m)==2){
if(n==0&&m==0) break;
ans=0;
L=1;
M=0;
a=n+1;
M=N[m]-1;
if(a>=M){
ans=N[M]-1;
}
else {
ans=N[n+1]-1;
L=N[n];
ans=ans+L*(M-n-1);
}
cout<<ans<<endl;
}
return 0;
}
MacaW Baby Learns Computer的更多相关文章
- 科技发展时间线(Technology Timeline)
本文主要记录,过去两百年间,科技发展的时间线 这些内容,是自己在学习电脑发展历史的时候做的, 感兴趣的同学,可以复制到 Excel 里面,按顺序逐一进行学习, 学习和整理的过程确实花了很长时间,但是并 ...
- Teaching Your Computer To Play Super Mario Bros. – A Fork of the Google DeepMind Atari Machine Learning Project
Teaching Your Computer To Play Super Mario Bros. – A Fork of the Google DeepMind Atari Machine Learn ...
- How do you explain Machine Learning and Data Mining to non Computer Science people?
How do you explain Machine Learning and Data Mining to non Computer Science people? Pararth Shah, ...
- newborn, infant, toddler以及baby的区别
1.An infant (from the Latin word infans, meaning "unable to speak" or "speechless&quo ...
- Learn English like a Baby – How to Sound Native
Learn English like a Baby – How to Sound Native Share Tweet Share Tagged With: tips & tricks Wha ...
- step 1:begin to identify something in english(to becaome a baby again)
long long ago , i think if i want to improve my english especially computer english . i must do so m ...
- 共享文件夹:The user has not been granted the requested logon type at this computer
场景重现 今天做一个项目测试,要用到虚拟机,于是在虚拟机(XP 32)上新建了一个共享的文件夹.然后我在Win7 机器上访问它得到如下的error 消息:
- Computer assisted surgery
Computer assisted surgery (CAS) represents a surgical concept and set of methods, that use computer ...
- Computer vision labs
积累记录一些视觉实验室,方便查找 1. 多伦多大学计算机科学系 2. 普林斯顿大学计算机视觉和机器人实验室 3. 牛津大学Torr Vision Group 4. 伯克利视觉和学习中心 Pro ...
随机推荐
- 理解 ARC 下的循环引用
本文由 伯乐在线 - nathanw 翻译,dopcn 校稿.未经许可,禁止转载!英文出处:digitalleaves.com.欢迎加入翻译组. ARC 下的循环引用类似于日本的 B 级恐怖片.当你刚 ...
- Office2010安装需要MSXML版本6.10.1129.0的方法
今天给朋友装Office2010,由于朋友之前使用的是绿化版的0ffice2007,所以卸载后安装Office遇到了若要安装Office2010,需要在计算机上安装MSXML版本6.10.1129.0 ...
- 使用keras导入densenet模型
从keras的keras_applications的文件夹内可以找到内置模型的源代码 Kera的应用模块Application提供了带有预训练权重的Keras模型,这些模型可以用来进行预测.特征提取和 ...
- opencv学习笔记——时间计算函数getTickCount()和getTickFrequency()
cv::getTickCount()可以用来测量一段代码的运行时间,这个函数返回从上次开机算起的时钟周期数. 由于我们需要的是某个代码段运行的毫秒数,因此还需要另一个函数cv::getTickFreq ...
- 在ubuntu下安装使用latex
参考:https://www.cnblogs.com/longdouhzt/archive/2012/09/27/2706358.html https://jingyan.baidu.com/albu ...
- Oracle Function:COUNT
Description The Oracle/PLSQL COUNT function returns the count of an expression. The COUNT(*) functio ...
- Gym - 101020H Weekend floyd+next_permutation
https://vjudge.net/problem/Gym-101020H 题意:正常读取方式给你一个图(双向的),然后给你f个点,让你找一条路从1到n的最短路,要求经过f个点(以任意顺序). 题解 ...
- MySQL在windows下的图形安装
1.mysql官网下载mysql-5.5.53-winx64.msi文件并保存到磁盘相应目录. 2.图形化安装mysql数据库: 1)双击mysql-5.5.53-winx64.msi,出现欢迎界面, ...
- three levels of abstraction
DATABASESYSTEM CONCEPTS SIXTH EDITION Abraham Silberschatz Yale University Henry F. KorthLehigh Univ ...
- Ubuntu下缓冲器溢出攻击实验(可以看看问题分析)
缓冲器溢出攻击实验题目: 下边的代码摘自<黑客攻防技术宝典——系统实战篇(第 2 版)>2.5 节,攻击该代码,获得root 权限,实现相应的效果. strcpy(little_array ...