triangle

CSS 三角形绘制方法

試著忘記壹切 提交于 2019-11-29 15:49:41
#triangle-up { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-bottom: 100px solid red; } #triangle-down { width: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 100px solid red; } #triangle-left { width: 0; height: 0; border-top: 50px solid transparent; border-right: 100px solid red; border-bottom: 50px solid transparent; } #triangle-right { width: 0; height: 0; border-top: 50px solid transparent; border-left: 100px solid red; border-bottom: 50px solid transparent; } #triangle-topleft {

每日一题_190914

荒凉一梦 提交于 2019-11-29 12:24:20
在 \(\triangle ABC\) 中, \(\sin \dfrac{\angle ABC}{2}=\dfrac{\sqrt{3}}{3}\) , 点 \(D\) 在线段 \(AC\) 上, 且 \(AD=2DC\) , \(BD=\dfrac{4\sqrt3}{3}\) , 则 \(\triangle ABC\) 的面积的最大值为 \(\underline{\qquad\qquad}\) . 解析: 法一 根据题意有 \[ \cos\angle ABC=1-2\sin^2\dfrac{\angle ABC}{2}=\dfrac 13.\] 因此 \(\angle ABC\) 是一个大小确定的锐角, 并且 \(\tan\angle ABC = 2\sqrt 2\) . 如图, 建立平面直角坐标系. 设 \(\theta=\angle DBC, C(x,0)\) . 则 \(D\) 点坐标为 \[ \begin{cases} & x_D=BD\cdot \cos\theta=\dfrac{4\sqrt{3}}{3}\cos\theta,\\ & y_D=BD\cdot \sin\theta=\dfrac{4\sqrt{3}}{3}\sin\theta. \end{cases}\] 又 \(D\) 点是线段 \(AC\) 上靠近 \(C\) 点的三等分点, 从而 \(A\)

119. Pascal's Triangle II (E)

半腔热情 提交于 2019-11-29 11:24:49
Pascal’s Triangle II (E) Given a non-negative index k where k ≤ 33, return the k t h k^{th} k t h 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. Example: Input: 3 Output: [1,3,3,1] Follow up: Could you optimize your algorithm to use only O ( k ) extra space? 题意 求出帕斯卡(杨辉)三角形的指定行的元素。 思路 可以直接建二维数组进行模拟;也可以压缩至一维数组进行处理;最省空间的是直接根据杨辉三角形的组合数性质直接计算出指定行的所有元素,即 t r i a n g l e [ i ] [ j ] = C i j triangle[i][j]=C^j_i t r i a n g l e [ i ] [ j ] = C i j ​ 。 代码实现 - 二维数组 class Solution { public List

三角形最小路径和

荒凉一梦 提交于 2019-11-29 01:36:54
思路:相当于建了一个相同大小的dp表,从三角形的底层往上层走,dp表中的值表示从下层走到当前地方的最小值,dp的更新规则是找到当前位置的下一层的同位置点或者索引加一的点(看成二叉树的形式的话相当于左右子节点)的两者中的最小值和当前位置的值的和 class Solution(object): def minimumTotal(self, triangle): """ :type triangle: List[List[int]] :rtype: int """ res = [triangle[-1]] for i in range(len(triangle)-2, -1, -1): tmp = [0] * (i+1) for j in range(i, -1, -1): tmp[j] = min(res[0][j], res[0][j+1]) + triangle[i][j] res = [tmp] + res return res[0][0] 来源: https://www.cnblogs.com/dolisun/p/11437874.html

Triangle POJ - 2079 (旋转卡壳最大三角形)

六眼飞鱼酱① 提交于 2019-11-28 22:59:53
Given n distinct points on a plane, your task is to find the triangle that have the maximum area, whose vertices are from the given points. Input The input consists of several test cases. The first line of each test case contains an integer n, indicating the number of points on the plane. Each of the following n lines contains two integer xi and yi, indicating the ith points. The last line of the input is an integer −1, indicating the end of input, which should not be processed. You may assume that 1 <= n <= 50000 and −10 4 <= xi, yi <= 10 4 for all i = 1 . . . n. Output For each test case,

用CSS样式写选择框右侧小三角

[亡魂溺海] 提交于 2019-11-28 21:50:26
本文转载于: 猿2048 网站 用CSS样式写选择框右侧小三角 直接上代码! <!DOCTYPE html> <html lang="en"> <head> <title>小三角</title> <style> .up-triangle{ width:0px; height:0px; border-bottom:30px solid #000; border-left:15px solid transparent; border-right:15px solid transparent; margin:100px auto; } .down-triangle{ width:0px; height:0px; border-top:30px solid #000; border-left:15px solid transparent; border-right:15px solid transparent; margin:100px auto; } .left-triangle{ width:0px; height:0px; border-right:30px solid #000; border-top:15px solid transparent; border-bottom:15px solid transparent; margin:100px auto; } .right

代码-动态规划

谁说我不能喝 提交于 2019-11-28 03:26:48
1.动态规划 三角形问题 1 class Solution(object): 2 def minimumTotal(self, triangle): 3 """ 4 :type triangle: List[List[int]] 5 :rtype: int 6 """ 7 dp = triangle 8 length = len(triangle) 9 for i in range(1,length): 10 for j in range(len(dp[i])): 11 if j == 0: 12 dp[i][j] = triangle[i][j] + dp [i-1][j] 13 elif j == len(dp[i])-1: 14 dp[i][j] = triangle[i][j] + dp [i-1][j-1] 15 else: 16 dp[i][j] = triangle[i][j] + min(dp[i-1][j-1], dp[i-1][j]) 17 return min(dp[length-1]) 来源: https://www.cnblogs.com/wb-learn/p/11389032.html

Hello Triangle_练习一:添加更多顶点到数据中,使用glDrawArrays,尝试绘制两个彼此相连的三角形

蹲街弑〆低调 提交于 2019-11-27 18:52:17
2019/11/26 1 #include <glad/glad.h> 2 #include <GLFW/glfw3.h> 3 4 #include <iostream> 5 6 void framebuffer_size_callback(GLFWwindow* window, int width, int height); 7 void processInput(GLFWwindow *window); 8 9 // settings 10 const unsigned int SCR_WIDTH = 800; 11 const unsigned int SCR_HEIGHT = 600; 12 13 const char *vertexShaderSource = "#version 330 core\n" 14 "layout (location = 0) in vec3 aPos;\n" 15 "void main()\n" 16 "{\n" 17 " gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n" 18 "}\0"; 19 const char *fragmentShaderSource = "#version 330 core\n" 20 "out vec4 FragColor;\n" 21 "void main

考试复习

只谈情不闲聊 提交于 2019-11-27 13:21:03
声明抽象基类Shape,由它派生出3个子类:Circle(圆形)、Rectangle(矩形)、Triangle(三角形),用一个函数printArea分别求出以上三者的面积,三个图形的数据在定义对象时给定。再设计一个函数sumArea,求出三个图形面积之和。要求用基类指针数组,使它的每一个元素指向一个派生类对象。 View Code #include <iostream> #include <cmath> using namespace std; const double PI = acos(-1.0); class Shape { public: virtual double getArea() = 0; }; class Circle : public Shape { private: double R; public: Circle(double r = 0) : R(r) {}; double getArea() { return PI * R * R; } }; class Rectangle : public Shape { private: double len,high; public: Rectangle(double l = 0, double h = 0) : len(l), high(h) {}; double getArea() { return len

POJ2079 Triangle

痴心易碎 提交于 2019-11-26 15:50:14
题目链接 问题分析 假的题目,假的数据…… 不可能有少于 \(O(n^2)\) 的做法的,少于 \(O(n^2)\) 的做法是不可能的。 然而由于假的数据,凸包上的点只有不到 \(3000\) 个,所以 \(n^2\) 就好了…… 参考程序 #include <cmath> #include <algorithm> #include <cstdio> #define LL long long using namespace std; const LL Maxn = 50010; struct point { LL x, y; point() {} point( LL _x, LL _y ) : x( _x ), y( _y ) {} inline point operator - ( const point Other ) const { return point( x - Other.x, y - Other.y ); } inline LL operator * ( const point Other ) const { return x * Other.y - y * Other.x; } inline LL Dis() const { return x * x + y * y; } }; LL N, M; point A[ Maxn ], B[ Maxn ]; bool