题目链接:uva 11401 - Triangle Counting
题目大意:有多少种方法可以从1,2,3...n中选出3个不同的数组成三角形,给出n,求种数。
解题思路:加法原理,设最大边为x的三角形有c(x)个,那么另外两条边长分别为y和z,根据三角形的形式可以的y+z>x,所以z的范围即为x?yzx
根据这个不等式可以得到每个y值所对应的z值个数,为等差数列,所以
c(...
分类:
其他好文 时间:
2014-05-15 03:03:34
阅读次数:
248
TriangleGiven 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...
分类:
其他好文 时间:
2014-05-13 18:51:44
阅读次数:
297
1、
??
Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama" is a palindrom...
分类:
其他好文 时间:
2014-05-13 07:06:35
阅读次数:
284
Delta-wave
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5447 Accepted Submission(s): 2063
Problem Description
A triangle field i...
分类:
其他好文 时间:
2014-05-11 19:56:01
阅读次数:
349
Triangle
Time Limit: 3000MS
Memory Limit: 30000K
Total Submissions: 8038
Accepted: 2375
Description
Given n distinct points on a plane, your task is to find the triangl...
分类:
其他好文 时间:
2014-05-11 06:36:44
阅读次数:
425
我的那个暴力求解,太耗时间了。用了网上产的什么因式分解,质因数之类的。确实快!还是数学基础不行,只能知道大约。The
sequence of triangle numbers is generated by adding the natural numbers. So the
7th triangl...
分类:
其他好文 时间:
2014-05-09 23:43:16
阅读次数:
342
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 fol...
分类:
编程语言 时间:
2014-05-08 18:31:51
阅读次数:
399
很简单的一道DP,看到空间限制是O(N)的,不要习惯性的以为是要保存每一行的最小值,不难想到是要保存一行当中各个数为路径终点时的和的大小。当算到最后一行时,就是从顶部到底部以这个底部位置为终点的最短路径和,找一个最小的就可以了。
实现的时候要注意个问题,因为计算时要用到上一行的数据,所以为了避免数据被覆盖,应该从后往前算,这个技巧用的很多,相信大家都很熟悉。
ac代码如下:
class So...
分类:
其他好文 时间:
2014-05-08 04:01:44
阅读次数:
282
Chef and The Right Triangles
The Chef is given a list of N triangles. Each triangle is identfied by the coordinates of its three corners in the 2-D cartesian plane. His job is to figure out how m...
分类:
其他好文 时间:
2014-05-07 16:28:35
阅读次数:
314