SGU 299.Triangle】的更多相关文章

题意: 给出n(<=1000)条线段的长度ai(<=10^500),输出任意三条能组成三角形的边.没有输出3个0. Solution: 简单题.只是要处理高精度. java大法好. import java.util.*; import java.math.*; public class Solution { public static void main(String[] args){ Scanner cin=new Scanner(System.in); int n=cin.nextInt(…
sgu 299 题意:给你n个线段,然后问你能不能选出其中三个组成一个三角形,数字很大 收获:另一个大整数模板 那么考虑下为什么如果连续三个不可以的话,一定是不存在呢? 连续上个不合法的话,一定是 ai-1 + ai-2 < = ai; 那么如果我们取右边的数,那是不是aj ,那么aj >= ai就更不可能成立了, 取左边的一样可以证明出不可以 #include<bits/stdc++.h> #define de(x) cout<<#x<<"=&q…
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traffic Lights 最短路 104 Little Shop of Flowers 动态规划 105 Div 3 找规律 106 The Equation 扩展欧几里德 107 987654321 Problem 找规律 108 Self-numbers II 枚举+筛法递推 109 Magic of Dav…
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 [ [], [,4], [6,,7], [4,,8,3] ] The minimum path sum from top to bottom is 11 (i.e.,…
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? 杨辉三角想必大家并不陌生,应该最早出现在初高中的数学中,其实就是二项式系数的一种写法. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1…
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] ] 杨辉三角是二项式系数的一种写法,如果熟悉杨辉三角的五个性质,那么很好生成,可参见我的上一篇博文: http://www.cnblogs.com/grandyang/p/4031536.html 具体生…
题目简述: 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? 解题思路: 这里的关键是空间的使用,既然只能用O(K)很容易就想到我们要进行回卷(名字好像不对).我的做法是每一次都在后面新加入一个数…
题目简述: 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]] 解题思路: 很简单的问题,只要把两头的一拿出来,中间就是两个数相加了. class Solution: # @return a list of lists of integers def…
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 32923   Accepted: 19514 Description 73 88 1 02 7 4 44 5 2 6 5 (Figure 1) Figure 1 shows a number triangle. Write a program that calculates the hi…
Triangle - Delaunay Triangulator  eryar@163.com Abstract. Triangle is a 2D quality mesh generator and Delaunay triangulator. Triangle was created as part of the Quake project in the school of Computer Science at Carnegie Mellon University by Jonathan…