triangle

HRBUST 1004 The Triangle

匿名 (未验证) 提交于 2019-12-03 00:21:02
The Triangle Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 1944 (903 users) Total Accepted: 1077 (834 users) No Description 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1) Input Your program is to read from standard input. For each test case, the first line contains one integer N: the number of rows in the triangle. The following N lines describe the data of the triangle. The number of rows in the triangle is > 1 but <= 100. The numbers in the triangle, all integers, are between 0 and 99. Process to the end of file. Output For each test case, your program is to write to standard output. The

Android学习之OpenGL ES概述基础

匿名 (未验证) 提交于 2019-12-03 00:21:02
最近写一个有关视频的项目,需要用到GLSurfaceView,先自己琢磨琢磨。 在Android平台上使用OpenGL ES主要有两种方式:NDK和SDK。通过NativeActivity,应用在native(c/c++)中管理整个activity的声明周期,以及绘制过程。由于爱native代码中,可以访问OpenGL ES的代码,因此,可以认为NativeActivity提供了一个OpenGL ES的运行环境。同时,Android提供了两个可以运行在OpenGL ES的类:GLSurfaceView和TextureView。由于真正的OpenGL ES仍然运行在native在层,因此在performance上,使用SDK并不比NDK差。而避免了JNI,客观上对于APP开发者来说使用SDK要比NDK容易。而GLSurfaceView和GLSurfaceView.Renderer是使用OpenGL ES的基础: GLSurfaceView: 这个是我们使用OpenGL ES来进行绘制和操作的view,它和SurfaceView在功能上相似。 GLSurfaceView.Renderer: 这个接口定义了在GLSurfaceView上绘制的方法,我们必须将它实例化attach到GLSurfaceView。 onSurfaceCreated()

三角形的五心

匿名 (未验证) 提交于 2019-12-02 23:49:02
概述 三角形的五心包括重心、垂心、外心、内心和旁心,是解决三角形问题的一种工具,也是一种研究对象。 前置知识:三角形等积变换、轴对称、相似、圆 内容 重心 重心的概念 三角形三条中线的交点,叫做三角形的重心,三角形的重心在三角形的内部 如图,G为△ABC的重心 重心的性质 基本性质 三角形重心与顶点的距离等于它与对应中点的距离的两倍,即$\displaystyle \frac{AG}{GD}=\frac{BG}{GE}=\frac{CG}{GF}=2$ 证明1 由共边定理得 由蝴蝶定理得 于是有 由共边定理得$\frac{AG}{DG}=\frac{\triangle ACG}{\triangle CDG}=2$ 同理可推得其他边的关系 证明2 连接$DE$,由中位线得平行,得八字模型,由相似和中位线$\frac{1}{2}$得$2$倍 推论1 设$G$是$\triangle ABC$中一点,若$S_{\triangle ABG}=S_{\triangle ABC}=\frac{1}{3}S_{\triangle ABC}$,则$G$为$\triangle ABC$的重心 证明 由共边定理(燕尾模型)得$\frac{BD}{CD}=\frac{S_{\triangle ABG}}{S_{\triangle ACG}}=1$,即$G$为$\triangle ABC$中点 垂心 外心

列表习题

匿名 (未验证) 提交于 2019-12-02 23:37:01
#求100内的素数 从2开始到自身的-1的数中能找到一个能整除的,可转化为从2开始到自身开平方的数中找到一个能整除的 一个合数一定可以分解成几个素数的乘积,也就是说一个数如果可以被一个素数整除就是合数 法一: import math n = 100 lst = [] for x in range(2,n): for i in range lst: if x % i == 0: break else: print(x) lst.append(x) 法二: import math lst = [] flag = False for x in range(2,100): for i in lst: if x % i == 0: flag = True break if i >= math.ceil(math.sqrt(x)): flag = False break if not flag: print(x) lst.append(x) 法三: import math n = 100 pn = [] flag = False count = 0 for x in range(2,n): for i in pn: count += 1 if x % i == 0: flag = True break if i >= math.ceil(x**0.5): flag = False break

面向对象之静态方法、类方法

自作多情 提交于 2019-12-02 23:35:09
有些时候需要按条件选择性地创建对象,可以使用静态方法或者类方法达到目的。 1静态方法@staticmethod 之前,我们在类中定义的方法都是对象方法,也就是说这些方法都是发送给对象的消息。实际上,我们写在类中的方法并不需要都是对象方法,例如我们定义一个“三角形”类,通过传入三条边长来构造三角形,并提供计算周长的方法,但是传入的三条边长未必能构造出三角形对象,因此我们可以先写一个方法来验证三条边长是否可以构成三角形,这个方法很显然就不是对象方法,因为在调用这个方法时三角形对象尚未创建出来(因为都不知道三条边能不能构成三角形),所以这个方法是属于三角形类而并不属于三角形对象的。可以使用静态方法来解决这类问题。 class Triangle(object): def __init__(self, a, b, c): self._a = a self._b = b self._c = c @staticmethod def is_valid(a, b, c): return a + b > c and b + c > a and a + c > b def perimeter(self): return self._a + self._b + self._c def main(a,b,c): if Triangle.is_valid(a, b, c)==True: t =

[leetcode]611. Valid Triangle Number有效三角数

匿名 (未验证) 提交于 2019-12-02 23:32:01
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: Input: [2,2,3,4] Output: 3 Explanation: Valid combinations are: 2,3,4 (using the first 2) 2,3,4 (using the second 2) 2,2,3 Note: The length of the given array won't exceed 1000. The integers in the given array are in the range of [0, 1000]. 题意: 给定数组,可由数组中的数字组成多少个valid三角形 解本题的背景知识: 【Math fact】The sum of two sides of a triangle must be greater than the third one Solution1: Two Pointers (similar as 3

119. Pascal's Triangle II

我的未来我决定 提交于 2019-12-02 13:12:36
Given a non-negative index k where k ≤ 33, return the k th index row of the Pascal's triangle. Note that the row index starts from 0. In Pascal's triangle, each number is the sum of the two numbers directly above it. class Solution { public List<Integer> getRow(int rowIndex) { return generate(rowIndex + 1).get(rowIndex); } public List<List<Integer>> generate(int numRows) { List<List<Integer>> res = new ArrayList(); if(numRows == 0) return res; res.add(new ArrayList(Arrays.asList(1))); for(int i = 2; i <= numRows; i++){ Integer[] cur = new Integer[i]; Arrays.fill(cur,1); List<Integer> pre = res

6-6 请按照要求实现接口 (10 分)

空扰寡人 提交于 2019-12-02 11:41:50
6-6 请按照要求实现接口 (10 分) 创建一个直角三角形类Triangle类,实现下列接口Ishape。两条直角边长作为Triangle类的私有成员,类中包含参数为直角边的构造方法。 函数接口定义: 请详细阅读接口和主方法中的定义和调用。 裁判测试程序样例: import java . text . DecimalFormat ; interface Ishape { public abstract double getArea ( ) ; public abstract double getPerimeter ( ) ; } /*你写的代码将嵌入到这里*/ public class Main { public static void main ( String [ ] args ) { DecimalFormat d = new DecimalFormat ( "#.####" ) ; Ishape r = new Triangle ( 3.1 , 4.2 ) ; System . out . println ( d . format ( r . getArea ( ) ) ) ; System . out . println ( d . format ( r . getPerimeter ( ) ) ) ; } } 输入样例: 本题无输入 输出样例: 在这里给出相应的输出

Py||Judge triangle

谁说胖子不能爱 提交于 2019-12-02 11:02:00
题目描述 Write a program to determine if the given three edges can form a triangle. The types of triangles include: equilateral triangles, isosceles triangles, right triangles, regular triangles It is also possible that a triangle cannot be formed. 输入 The input consists of multiple lines of data, each line consisting of three positive integers, a, b, c representing the length of the three sides of the triangle. 输出 For each line of input, do the following processing and wrap: 1.If the triangle is an equilateral triangle, output DB. 2.If it is not an equilateral triangle, it is an isosceles triangle

每日一题_191030

岁酱吖の 提交于 2019-12-02 06:06:16
已知 \(\triangle ABC\) 的内角 \(A,B,C\) 所对的边分别为 \(a,b,c\) ,若 \(a=\sqrt{2}\) , \(b^2-c^2=6\) ,则角 \(A\) 最大时, \(\triangle ABC\) 的面积等于 \(\underline{\qquad\qquad}.\) 解析: 法一 由题有 \[ \begin{split} \cos A&=\dfrac{b^2+c^2-a^2}{2bc}=\dfrac{b^2+c^2-2}{2bc}\\ &=\dfrac{b^2+c^2-\dfrac{1}{3}\left(b^2-c^2\right)}{2bc}\\ &=\dfrac{b}{3c}+\dfrac{2c}{3b}\\ &\geqslant \dfrac{2\sqrt{2}}{3}. \end{split}\] 当且仅当 \[\left(\dfrac{b}{3c}=\dfrac{2c}{3b}\right)\land \left(b^2-c^2=6\right)\] 即 \((b,c)=\left(2\sqrt{3},\sqrt{6}\right)\) 时等号成立.因此 \(\cos A\) 的最小值为 \(\dfrac{2\sqrt{2}}{3}\) ,此时 \(A\) 最大,所求三角形面积为 \[ S_{\triangle ABC}=