码迷,mamicode.com
首页 >  
搜索关键字:square    ( 2122个结果
UVA 10023 - Square root(手算平方根)
题目:UVA 10023 - Square root(手算平方根) 题目链接 题目大意:求给定的一个数的平方根。 解题思路:用二分但是这个数太大了,就超时了。看题接后发现需要用一种手算平方根的算法。 算法:  先判断这个数是不是偶数位,是的话就第一次取前面的两位数,不是的话第一次就只取前面的一位数来作为被除数。接下来就是两位两位为一节来计算。  用前一次的计算结果乘上20+一个个位数a...
分类:其他好文   时间:2015-01-21 11:35:11    阅读次数:112
迭代法对数计算B的N次方 SICP 计算机程序的构造和解释 1.16
使用Scheme的对数迭代法:#lang racket;;N是偶数:b^n = (b^(n/2))^2(define (square x) (* x x));定义乘积函数(define (fast-expt b n);筛选 (expt-iter b n 1))(define (expt-iter ....
分类:其他好文   时间:2015-01-20 19:52:28    阅读次数:130
Red and Black ---路线问题
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he c...
分类:其他好文   时间:2015-01-20 13:31:48    阅读次数:148
斐波那契算法的对数解法 计算机程序的构造和解释 习题1.19
程序由Scheme语言编写,待会上别的语言实现。#lang racket;斐波那契对数法;筛选(define (fib n) (fib-iter 1 0 0 1 n)) (define (square x) (* x x)) (define (fib-iter a b p q count) (...
分类:编程语言   时间:2015-01-19 22:17:58    阅读次数:201
[C++]LeetCode: 110 Spiral Matrix II (螺旋写入矩阵)
题目: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the following matrix: [ [ 1, 2, 3 ], [ 8, 9, ...
分类:编程语言   时间:2015-01-19 19:13:19    阅读次数:189
[leetcode] 69 Sqrt(x)
问题描述: Implement int sqrt(int x). Compute and return the square root of x. 基本思路: 采用二分查找法; 犹豫输入x是int型 ,int最大范围是2147483647 ,所以返回结果的范围0-46340. 注意要根据确定的区间去查找正确的返回值,如果大于46340的数的平方将超出int的表示范围。 代码:...
分类:其他好文   时间:2015-01-18 17:18:16    阅读次数:99
ural 1073. Square Country 完全背包
点击打开链接 1073. Square Country Time limit: 1.0 second Memory limit: 64 MB There live square people in a square country. Everything in this country is square also. Thus, the Square P...
分类:其他好文   时间:2015-01-17 01:16:52    阅读次数:172
hdu1198 Farm Irrigation dfs
Problem Description Benny has a spacious farm land to irrigate. The farm land is a rectangle, and is divided into a lot of samll squares. Water pipes are placed in these squares. Different square has...
分类:其他好文   时间:2015-01-15 18:19:28    阅读次数:190
poj1020 Anniversary Cake 搜索
Description Nahid Khaleh decides to invite the kids of the "Shahr-e Ghashang" to her wedding anniversary. She wants to prepare a square-shaped chocolate cake with known size. She asks each invited pe...
分类:其他好文   时间:2015-01-15 11:07:01    阅读次数:244
Leetcode:Sqrt(x)
Implementint sqrt(int x).Compute and return the square root ofx.分析:二分查找。首先确定二分查找终止的条件和返回条件,其次对于与数字有关的题要注意int的表示范围防止溢出(比如该题两个int相乘可能会超过int的范围,故采用x/mid与...
分类:其他好文   时间:2015-01-14 22:36:12    阅读次数:221
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!