2014-05-08 21:33

题目链接

原题:

largest number that an int variable can fit given a memory of certain size

题目:给定特定内存大小,请问int型的变量能表示的最大整数是多少?

解法:这个“Guy”出的题目总是这样表意不清。特定大小的内存是什么意思?他要说的是字长吧?16位int占两字节,32位以后int都占四字节。这样能表示的最大整数就是(1 << sizeof(int) * 8  - 1) - 1。

代码:

 // http://www.careercup.com/question?id=4847954317803520
// For n bits, signed integer can reach 2 ^ (n - 1) - 1.
// For n bits, unsigned integer can reach 2 ^ n - 1.
// My question is: is this a real Google interview question? Onsite interview?
// This guy named 'guy' has been posting an awful lot of questions on Careercup, which contains some difficult, tricky, trivial and stupid ones.
// I doubt if he's simply trying to gather more reputation, by means of spam questions. If he's not telling the truth, he's polluting Careercup and misleading other visitors here.
// He should be warned and punished.
int main()
{
return ;
}

Careercup - Google面试题 - 4847954317803520的更多相关文章

  1. Careercup - Google面试题 - 5732809947742208

    2014-05-03 22:10 题目链接 原题: Given a dictionary, and a list of letters ( or consider as a string), find ...

  2. Careercup - Google面试题 - 5085331422445568

    2014-05-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, w ...

  3. Careercup - Google面试题 - 6332750214725632

    2014-05-06 10:18 题目链接 原题: Given a ,) (,) (,), (,) should be returned. Some suggest to use Interval T ...

  4. Careercup - Google面试题 - 5634470967246848

    2014-05-06 07:11 题目链接 原题: Find a shortest path ,) to (N,N), assume is destination, use memorization ...

  5. Careercup - Google面试题 - 5680330589601792

    2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealin ...

  6. Careercup - Google面试题 - 5424071030341632

    2014-05-08 22:55 题目链接 原题: Given a list of strings. Produce a list of the longest common suffixes. If ...

  7. Careercup - Google面试题 - 5377673471721472

    2014-05-08 22:42 题目链接 原题: How would you split a search query across multiple machines? 题目:如何把一个搜索que ...

  8. Careercup - Google面试题 - 6331648220069888

    2014-05-08 22:27 题目链接 原题: What's the tracking algorithm of nearest location to some friends that are ...

  9. Careercup - Google面试题 - 5692127791022080

    2014-05-08 22:09 题目链接 原题: Implement a class to create timer object in OOP 题目:用OOP思想设计一个计时器类. 解法:我根据自 ...

随机推荐

  1. ASP.NET验证控件一

    为了更好地创建交互式Web应用程序.加强应用程序安全性,程序开发人员应该对用户输入的内容进行验证. ASP.NET提供了一系列输入验证控件,使用这些控件用户可以很方便地实现输入验证. ASP.NET还 ...

  2. 将Application按钮从任务栏中去掉

    SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);

  3. docker开发_在basic image的基础上创建自定义的image

    方法一:docker commit 1. 跑一个basic image,docker新建了一个容器 root@ubuntu:/home/thm/docker/test# docker run -i - ...

  4. Ajax清除浏览器js、css、图片缓存的方法

    做东东时都是把图片在服务器的地址存放在数据库里面,然后到浏览器中显示,但是后来发现了两个问题. 第一:为了安全起见,js是无法读取本地的图片的,不然你写一个js,岂不是可以获取任何人电脑里面的文件了. ...

  5. Python-2.7.11+Django-1.9.4安装配置

    1.去python官网下载2.7的最新版本 https://www.python.org/downloads 1.1 解压Python-2.7.11.tgz tar xvf Python-2.7.11 ...

  6. Apache与Nginx的优缺点

    http://weilei0528.blog.163.com/blog/static/206807046201321810834431 Apache与Nginx的优缺点比较 1.nginx相对于apa ...

  7. javascript的变量,传值和传址,参数之间关系

    先把收获晾一下: 1.javascrip变量包含两种类型的值,一种为引用类型的值,一种是基本类型的值.引用类型包括:Array,Object,Function(可以这么理解,非基本类型的都是引用类型) ...

  8. Android sqlite3工具的使用

    sqlite3 <数据库名称> 进入数据库操作模式 eg: sqlite3 contacts.db .tables 查看所有的表 eg: .table .schema 查看查看库中所有表的 ...

  9. 给Activity设置背景颜色

    为了使得错误提示更加显眼,再用Toast+振动效果之外考虑变换整个activity的背景颜色. 尝试一: activity并没像winform一样直接给个属性来设置,就想获取整个activity的la ...

  10. Windows 上如何安装Sqlite(转载)

    1.获得命令行程序 SQLite命令行程序(CLP)是开始使用SQLite的最好选择,按照如下步骤获取CLP: 1).打开浏览器进入SQLite主页,   www.sqlite.org. 2).单击页 ...