A - Macaw Baby Learns Computer

Time Limit:1000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

Submit Status

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.0000005.0000006.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的更多相关文章

  1. 科技发展时间线(Technology Timeline)

    本文主要记录,过去两百年间,科技发展的时间线 这些内容,是自己在学习电脑发展历史的时候做的, 感兴趣的同学,可以复制到 Excel 里面,按顺序逐一进行学习, 学习和整理的过程确实花了很长时间,但是并 ...

  2. 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 ...

  3. 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, ...

  4. newborn, infant, toddler以及baby的区别

    1.An infant (from the Latin word infans, meaning "unable to speak" or "speechless&quo ...

  5. 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 ...

  6. 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 ...

  7. 共享文件夹:The user has not been granted the requested logon type at this computer

    场景重现 今天做一个项目测试,要用到虚拟机,于是在虚拟机(XP 32)上新建了一个共享的文件夹.然后我在Win7 机器上访问它得到如下的error 消息:

  8. Computer assisted surgery

    Computer assisted surgery (CAS) represents a surgical concept and set of methods, that use computer ...

  9. Computer vision labs

    积累记录一些视觉实验室,方便查找 1.  多伦多大学计算机科学系 2.  普林斯顿大学计算机视觉和机器人实验室 3.  牛津大学Torr Vision Group 4.  伯克利视觉和学习中心 Pro ...

随机推荐

  1. EJBCA的安装(基于Ubuntu 16.04 LTS + wildfly8 + ejbca6.3.11 + jdk7)

    前一段时间折腾了一下PKI,用EJBCA在研究院内网搭建了一个CA,目前是提供给手机端(安卓和IOS)来和服务器端(nginx + Java应用)做安全连接的(客户端和服务器端双向认证) 由于EJBC ...

  2. windows网卡共享网络时,报Internet连接共享访问被启用时,出现了一个错误。(null)

    今天笔者在自己电脑上作试验时,准备将无线网络连接共享给VMnet1时报Internet连接共享访问被启用时,出现了一个错误.(null)错误: 经上网查询到问题原因:没有启用 Windows Fire ...

  3. Shell脚本导入外部脚本内容

    vim subscript.sh #!/bin/bash tool="ApacheSpark" vim main.sh #!/bin/bash source /home/wx/su ...

  4. C++虚函数virtual,纯虚函数pure virtual和Java抽象函数abstract,接口interface与抽象类abstract class的比较

    由于C++和Java都是面向对象的编程语言,它们的多态性就分别靠虚函数和抽象函数来实现. C++的虚函数可以在子类中重写,调用是根据实际的对象来判别的,而不是通过指针类型(普通函数的调用是根据当前指针 ...

  5. easyui_1

    --- easyui.css包括所有组件的css,

  6. 2018牛客网暑期ACM多校训练营(第一场) J - Different Integers - [莫队算法]

    题目链接:https://www.nowcoder.com/acm/contest/139/J 题目描述  Given a sequence of integers a1, a2, ..., an a ...

  7. Pandas的index属性

    我们在统计数据的长度或者个数,不用统计去专门获取数值,而是用index这个数据获取即可,DataFrame的index直接就是最前面的索引号,如果要统计列的个数,使用DataFrame.colums获 ...

  8. 图论最短路——spfa

    今天开始图论的最短路的最后复习,今天自己手打spfa虽然看了一眼书,但是也算是自己打出来的,毕竟很久没打了,而且还是一遍a代码下来15min左右就搞完了,成就感++.所以呢来篇博客记录一下. 香甜的黄 ...

  9. LCA——最近公共祖先

    今天终于把倍增的LCA搞懂了!尽管周测都没写,尽管lca其实很简单,但这也是进度君的往前一点点的快乐.学渣的呻吟. 倍增的lca其实关键就在于二进制的二进制的拆分(显然是两次的拆分,很奇妙,懂二进制的 ...

  10. Ancient Go---hdu5546(dfs爆搜CCPC题目)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5546 题意就是两个人下围棋,问在下一颗x是否能杀死o,'.'是空位子: 枚举所有的点,判断是否合法即可 ...