《Cracking the Coding Interview》——第7章:数学和概率论——题目5
2014-03-20 02:20
题目:给定二维平面上两个正方形,用一条直线将俩方块划分成面积相等的两部分。
解法:穿过对称中心的线会将面积等分,所以连接两个中心即可。如果两个中心恰好重合,那么任意穿过这个点的直线都满足条件。
代码:
- // 7.5 Given two squares on two-dimensional plane, draw a line to cut them in two parts with equal area.
- // Answer:
- // Apparently the line should go through the center of the two squares.
- // If their center coincide, any line that goes through this center will suffice.
- int main()
- {
- return ;
- }
《Cracking the Coding Interview》——第7章:数学和概率论——题目5的更多相关文章
- Cracking the coding interview 第一章问题及解答
Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...
- 《Cracking the Coding Interview》读书笔记
<Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...
- Cracking the coding interview
写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...
- Cracking the coding interview目录及资料收集
前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...
- Cracking the Coding Interview(Trees and Graphs)
Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...
- Cracking the Coding Interview(Stacks and Queues)
Cracking the Coding Interview(Stacks and Queues) 1.Describe how you could use a single array to impl ...
- 《Cracking the Coding Interview》——第7章:数学和概率论——题目7
2014-03-20 02:29 题目:将质因数只有3, 5, 7的正整数从小到大排列,找出其中第K个. 解法:用三个iterator指向3, 5, 7,每次将对应位置的数分别乘以3, 5, 7,取三 ...
- 《Cracking the Coding Interview》——第7章:数学和概率论——题目6
2014-03-20 02:24 题目:给定二位平面上一堆点,找到一条直线,使其穿过的点数量最多. 解法:我的解法只能适用整点,对于实数坐标就得换效率更低的办法了.请参见LeetCode - Max ...
- 《Cracking the Coding Interview》——第7章:数学和概率论——题目4
2014-03-20 02:16 题目:只用加法和赋值,实现减法.乘法.除法. 解法:我只实现了整数范围内的.减法就是加上相反数.乘法就是连着加上很多个.除法就是减到不能减为止,数数总共减了多少个. ...
随机推荐
- 我的visual studio 配色方案 Rubik c++版
只是更改了c++的配色,放出来与大家分享,因为大胆地采用了各种颜色,所以我把它取名叫做Rubik,因为Rubik‘s cube也就是魔方,我本人是非常喜欢魔方的,然后也符合颜色丰富多彩的这个特征,希望 ...
- Sublime插件支持Sass编译和Babel解析ES6 & .sublime-build文件初探(转载自imwtr)
原文请看:http://www.cnblogs.com/imwtr/p/6010550.html 用Sublime Text蛮久了,配置配来配去的,每次换电脑都得重头再配过,奈何人老了脑子不中用了 ...
- Leetcode 46 47 Permutation, 77 combination
Permutation class Solution { List<List<Integer>> res = new ArrayList<List<Integer& ...
- Spring转换编码utf-8方式
方式一:修改Spring配置文件(建议使用) <mvc:annotation-driven> <mvc:message-converters register-defaults=&q ...
- 第24章 SPI—读写串行FLASH—零死角玩转STM32-F429系列
第24章 SPI—读写串行FLASH 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/ ...
- rnn,cnn
http://nikhilbuduma.com/2015/01/11/a-deep-dive-into-recurrent-neural-networks/ 按照这里的介绍,目前比较火的cnn是fee ...
- android 圆角图片的实现形式
android 圆角图片的实现形式,包括用第三方.也有系统的.比如makeramen:roundedimageview,系统的cardview , glide .fresco . compile 'c ...
- Spring MVC 接收前端参数的方式
方式一: 普通方式接收 1 @RequestMapping("/index") 2 public String getUserName(String username) { 3 S ...
- C#基础-面向对象-封装
封装 命名空间 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApp6 { c ...
- give me something new 无用但有趣
屏保系列 http://www.asty.org/cmatrix/dist/cmatrix-1.2a.tar.gz //数码雨 libaa-bin //燃烧 海洋馆 http://search.cp ...