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

  1. Cracking the coding interview 第一章问题及解答

    Cracking the coding interview 第一章问题及解答 不管是不是要挪地方,面试题具有很好的联系代码总用,参加新工作的半年里,做的大多是探索性的工作,反而代码写得少了,不高兴,最 ...

  2. 《Cracking the Coding Interview》读书笔记

    <Cracking the Coding Interview>是适合硅谷技术面试的一本面试指南,因为题目分类清晰,风格比较靠谱,所以广受推崇. 以下是我的读书笔记,基本都是每章的课后习题解 ...

  3. Cracking the coding interview

    写在开头 最近忙于论文的开题等工作,还有阿里的实习笔试,被虐的还行,说还行是因为自己的水平或者说是自己准备的还没有达到他们所需要人才的水平,所以就想找一本面试的书<Cracking the co ...

  4. Cracking the coding interview目录及资料收集

    前言 <Cracking the coding interview>是一本被许多人极力推荐的程序员面试书籍, 详情可见:http://www.careercup.com/book. 第六版 ...

  5. Cracking the Coding Interview(Trees and Graphs)

    Cracking the Coding Interview(Trees and Graphs) 树和图的训练平时相对很少,还是要加强训练一些树和图的基础算法.自己对树节点的设计应该不是很合理,多多少少 ...

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

  7. 《Cracking the Coding Interview》——第7章:数学和概率论——题目7

    2014-03-20 02:29 题目:将质因数只有3, 5, 7的正整数从小到大排列,找出其中第K个. 解法:用三个iterator指向3, 5, 7,每次将对应位置的数分别乘以3, 5, 7,取三 ...

  8. 《Cracking the Coding Interview》——第7章:数学和概率论——题目6

    2014-03-20 02:24 题目:给定二位平面上一堆点,找到一条直线,使其穿过的点数量最多. 解法:我的解法只能适用整点,对于实数坐标就得换效率更低的办法了.请参见LeetCode - Max ...

  9. 《Cracking the Coding Interview》——第7章:数学和概率论——题目4

    2014-03-20 02:16 题目:只用加法和赋值,实现减法.乘法.除法. 解法:我只实现了整数范围内的.减法就是加上相反数.乘法就是连着加上很多个.除法就是减到不能减为止,数数总共减了多少个. ...

随机推荐

  1. 【CSS古话今说】-- 01.神奇的CSS-BFC在实战中的应用

    文章首发于掘金 BFC(Block Formatting Context)是Web页面中盒模型布局的CSS渲染模式.它的定位体系属于常规文档流. 想要实现一个BFC布局需要满足以下条件之一: 1.fl ...

  2. 859. Buddy Strings (wrong 4 times so many cases to test and consider) if else**

    Given two strings A and B of lowercase letters, return true if and only if we can swap two letters i ...

  3. 2018.7.5 jQuery学习

    <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...

  4. bootstarp v3 学习简记

    1.快速设置浮动通过这两个class让页面元素左右浮动. !important被用来避免某些问题. <div class="pull-left">...</div ...

  5. ILSVRC2014检测总结

    ILSVRC 2014结束一段时间了.从下面的表格来看,基本都是RCNN的路子,但是这些牛队都做了改进.自己和人家比差的太远啊,努力. team results Spotlights and impr ...

  6. windows安装配置mongodb及图形工具MongoVUE

    解压安装包到D:\Program Files\mongodb 建立数据库目录 D:\Program Files\mongodb\data 建立日志目录 D:\Program Files\mongodb ...

  7. java基础 序列化反序列化流 实现Serializable 接口 自动装载序列号到对象文本文件如修改不能反序列化对象文本,除非自定义long型常量 打印流

    package com.swift.baseKnowledge; import java.io.File; import java.io.FileInputStream; import java.io ...

  8. LeetCode804. Unique Morse Code Words

    题目 国际摩尔斯密码定义一种标准编码方式,将每个字母对应于一个由一系列点和短线组成的字符串, 比如: "a" 对应 ".-", "b" 对应 ...

  9. BZOJ4198: [Noi2015]荷马史诗(哈夫曼树)

    Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 1824  Solved: 983[Submit][Status][Discuss] Descripti ...

  10. MySQL另类的备份恢复方法——innodb可传输表空间

      Preface       There're many ways in backing up or migrating data from one server to another one.Lo ...