TheTriangleDivisionoftheConvexPolygon题意:求 n 凸多边形可以有多少种方法分解成不相交的三角形,最后值模 m。思路:卡特兰数的例子,只是模 m 让人头疼,因为 m 不一定是素数,所以不一定存在逆元。 解法:式子为f(n) = ( C( 2*(n-2), (...
分类:
其他好文 时间:
2014-12-01 12:42:11
阅读次数:
186
给定行号,输出如下所示Pascal Triangle(杨辉三角)For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]思路,想到右上一个构建下一个,构成过程就是上一个的相邻...
分类:
其他好文 时间:
2014-11-30 23:09:06
阅读次数:
232
题目链接:点击打开链接
首先要n-=2,然后就是一个卡特兰数了。
上一题用的是 h(n) = h(n-1) * (4n-2)/(n+1);
这题用的是 h(n) = (2n)! * n! / (n+1)!;
然后对阶乘分解质因数:
点击打开链接
分解完了直接快速幂。
#include
#include
#include
#include
using namespace std;
#d...
分类:
其他好文 时间:
2014-11-29 16:04:29
阅读次数:
284
Pascal's Triangle IIGiven an indexk, return thekthrow of the Pascal's triangle.For example, givenk= 3,Return[1,3,3,1].Note:Could you optimize your alg...
分类:
其他好文 时间:
2014-11-28 17:56:14
阅读次数:
193
ExplanationExtend Widget3D class to create a new 3D widget.Assign a VTK actor to the widget.Set color of the widget.Construct a triangle widget and di...
分类:
其他好文 时间:
2014-11-28 16:13:07
阅读次数:
185
Given an index k, return the kth row of the Pascal's triangle.
For example, given k = 3,
Return [1,3,3,1].
Note:
Could you optimize your algorithm to use only O(k) extra space?
这个问题比较简单。
v...
分类:
其他好文 时间:
2014-11-26 14:23:25
阅读次数:
245
【题意分析】本题就是在给定的N条边(边长是1,2,3,,,N)里面找合乎要求的三角形个数(任意两条边之和大于第三边)。如果我们直接枚举合乎题意的三角形那么我们不太好出发(想想为什么?),那么我们可以采用补集观念,先找出不合乎要求的三角形数目,再用总的组合数减去不合乎要求的数目,就得最后的结果。那么问...
分类:
其他好文 时间:
2014-11-26 01:19:07
阅读次数:
197
以下代码是THREE.JS 源码文件中Math/Triangle.js文件的注释.
barycoordFromPoint方法通过计算返回参数a,b,c所组成的三角形所在的平面上任意点(参数point)所表示三角形顶点的加权平均值,这个权值就是重心坐标.
NOTE:重心坐标的定义
三角形所在平面的任意点都能表示为顶点的加权平均值,这个权就叫做重心坐标。从重心坐标到标准坐标的转换为(无论2D或3D,连4D、5D也是这样):
(b1,b2,b3) b1v1+b2v2+b3v3
式中:b1,b2,b3...
分类:
Web程序 时间:
2014-11-21 23:21:51
阅读次数:
306
GivennumRows, generate the firstnumRowsof Pascal's triangle.Java:public class Solution { public List> generate(int numRows) { List> result =...
分类:
其他好文 时间:
2014-11-21 18:28:39
阅读次数:
136
题目描述:
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
For example, given the following triangle
[
[2],
...
分类:
其他好文 时间:
2014-11-20 12:03:48
阅读次数:
157