#include
#include
using namespace std;
class Triangle
{
public:
double perimeter();//计算三角形的周长
double area();//计算并返回三角形的面积
void showMessage();
Triangle(double x, double y, double z) :a(x), b(y...
分类:
其他好文 时间:
2015-04-27 21:47:16
阅读次数:
86
problem:
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
[
...
分类:
其他好文 时间:
2015-04-27 09:43:11
阅读次数:
136
GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]...
分类:
其他好文 时间:
2015-04-26 18:18:33
阅读次数:
131
因为题目说了,两个人之间总有一个人喜欢另一个人,而且不会有两个人互相喜欢。所以只要所给的图中有一个环,那么一定存在一个三元环。所以用拓扑排序判断一下图中是否有环就行了。 1 #include 2 #include 3 4 const int maxn = 2000 + 10; 5 char G...
分类:
编程语言 时间:
2015-04-25 22:42:17
阅读次数:
168
题意:给出n个人,如果a喜欢b,那么b一定不喜欢a,如果b不喜欢a,那么a一定喜欢b就是这n个点里面的任意两点都存在一条单向的边, 所以如果这n个点不能构成拓扑序列的话,就一定成环了,成环的话就一定能够找到一个三元环所以只需要判断能不能构成拓扑序列另外,tle了一晚上是因为用了cin------55...
分类:
编程语言 时间:
2015-04-25 22:23:09
阅读次数:
192
和nyoj613(免费馅饼)一样的原理 从下 网上依次遍历 存贮最大值
#include
#include
using namespace std;
int main()
{
int n,num[105][105]={0};
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=1;j<=i;j++)
scanf("%d",&num[i]...
分类:
其他好文 时间:
2015-04-25 21:18:00
阅读次数:
148
打印杨辉三角指定行,返回vector类型。【思路】1.照搬前面一道题,保存所有行;2.最小空间复杂度0(n),也是题目要求。即每一行覆盖上一行,为了保证不提前覆盖有效值,需要从后向前算。【other code】vector getRow(int rowIndex) { vector r...
分类:
其他好文 时间:
2015-04-24 16:04:37
阅读次数:
116
打印杨辉三角:[ [1], [1,1], [1,2,1], [1,3,3,1],[1,4,6,4,1]]输入打印的行数,返回vector >类型。【思路】1.我的思路是,先分配vector的空间,用resize,再用下标访问[i]。2.别人的思路,每行都是一个新vector cur,赋值后push_...
分类:
其他好文 时间:
2015-04-24 15:47:41
阅读次数:
131
problem:
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 spac...
分类:
其他好文 时间:
2015-04-24 12:40:14
阅读次数:
151
problem:
Given numRows, generate the first numRows of Pascal's triangle.
For example, given numRows = 5,
Return
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
]
Hid...
分类:
其他好文 时间:
2015-04-24 10:34:07
阅读次数:
102