UVa 1643 Angle and Squares (计算几何)】的更多相关文章

题意:有n个正方形和一个角(均在第一象限中),使这些正方形与这个角构成封闭的阴影区域,求阴影区域面积的最大值. 析:很容易知道只有所有的正方形的对角形在一条直线时,是最大的,然后根据数学关系,就容易得到答案. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #incl…
题意: 如图,有n个正方形和一个角(均在第一象限中),使这些正方形与这个角构成封闭的阴影区域,求阴影区域面积的最大值. 分析: 直观上来看,当这n个正方形的对角线在一条直线上时,封闭区域的面积最大.(虽然我不太会证明,=_=||) 设所有正方形边长之和为L,OA.OB两直线方程分别为:y = k1x  y = k2x,设A(x1, k1x1), B(x2, k2x2),可列出方程: ,解得,相应的就得到AB两点坐标,用叉积算出△OAB的面积再减去这些正方形面积的一半就是答案. #include…
题意:第一象限里有一个角,把n(n <= 10)个给定边长的正方形摆在这个角里(角度任意),使得阴影部分面积尽量大. 分析:当n个正方形的对角线在一条直线上时,阴影部分面积最大. 1.通过给定的xa,ya,xb,yb,可求k1,k2. 2.当n个正方形的对角线在一条直线上时,设A(x1,k1*x1),B(x2,k2*x2), 可列方程组: 解得 3.利用叉积算出AOB的面积,再减去正方形面积和的一半. #pragma comment(linker, "/STACK:102400000, 1…
直观感觉对角线重合的时候面积最大 然后可以根据方程和割补算出阴影部分的面积 注意知道两点坐标,可以求出与原点形成的三角形的面积 用叉乘,叉乘的几何意义以这两个向量为边的平行四边形的面积 所以用叉乘除以2就可以 (x1, y1), (x2, y2),叉乘为x1y2-y1x2 #include<cstdio> #include<cmath> #include<algorithm> #define REP(i, a, b) for(int i = (a); i < (b…
Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see a triangle ABC. Point D, E and F divides the sides BC, CA and AB into ratio 1:2 respectively. That is CD=2BD, AE=2CE and BF=2AF. A, D; B, E and C, F…
Problem B Board Wrapping Input: standard input Output: standard output Time Limit: 2 seconds The small sawmill in Mission, British Columbia, has developed a brand new way of packaging boards for drying. By fixating the boards in special moulds, the b…
D - Kadj Squares Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description In this problem, you are given a sequence S1, S2, ..., Sn of squares of different sizes. The sides of the squares are integer numb…
题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const double eps=1e-8; int dcmp(double x) { if(fabs(x)<eps) return 0; else return (x<0)?-1:…
题目链接 lrj训练指南 P259 //==================================================================== Point getP(Point A,Point B,Point C) { double a1=Angle(A-B,C-B); Vector v1=Rotate(C-B,a1/); double a2=Angle(A-C,B-C); Vector v2=Rotate(B-C,-a2/); return GetLineIn…
题目链接:http://poj.org/problem?id=2002 给定一堆点,求这些点里哪些点可以构成正方形,题目给定n<=1000,直接枚举四个点是肯定会超时的,因此要做一些优化. 有公式,已知两个点在正方形对角,分别是(x1,y1)和(x2,y2),那么围成正方形后另外两个点(x3,y3)和(x4,y4)分别为: x3 = x2 - (x2 - y1) y3 = x2 + (x2 - x1) x4 = x1 - (x2 - y1) y4 = y1 + (x2 - x1) 那么我们需要枚…