题意:第一象限里有一个角,把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, 102400000")
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define Min(a, b) ((a < b) ? a : b)
#define Max(a, b) ((a < b) ? b : a)
const double eps = 1e-8;
inline int dcmp(double a, double b) {if(fabs(a - b) < eps)  return 0;return a < b ? -1 : 1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 1000 + 10;
const int MAXT = 10000 + 10;
using namespace std;
struct Point{double x, y;void set(double xx, double yy){x = xx;y = yy;}
};
double getArea(Point &A, Point &B){return A.x * B.y - A.y * B.x;
}
int main(){int N;while(scanf("%d", &N) == 1){if(!N) return 0;Point A, B;scanf("%lf%lf%lf%lf", &A.x, &A.y, &B.x, &B.y);double L = 0;double area = 0;for(int i = 0; i < N; ++i){double l;scanf("%lf", &l);L += l;area += l * l / 2;}double k1 = A.y / A.x;double k2 = B.y / B.x;if(k1 > k2){swap(k1, k2);}double x1 = (k2 + 1) * L / (k2 - k1);double y1 = k1 * x1;double x2 = (k1 + 1) * L / (k2 - k1);double y2 = k2 * x2;A.set(x1, y1);B.set(x2, y2);double ans = getArea(A, B) / 2 - area;printf("%.3lf\n", ans);}return 0;
}

  

转载于:https://www.cnblogs.com/tyty-Somnuspoppy/p/6389477.html

UVA - 1643 Angle and Squares (角度和正方形)(几何)相关推荐

  1. Cesium坐标转换:已知两点,计算以一个点为圆心,将另一个点旋转一定度数后的新点的坐标/position_A绕position_B逆时针旋转angle度(角度)得到新点

    //position_A绕position_B逆时针旋转angle度(角度)得到新点 function rotatedPointByAngle(position_A, position_B, angl ...

  2. UVA12113 Overlapping Squares重叠的正方形 暴力破解

    题意:给定一个4*4的棋盘,用不超过6个2*2的纸片堆放出给出的图案,问是否可行 分析:题目很简单,不难想到枚举纸片位置,每张纸片有9中放置方法,只有6张纸片,可以断定不会超时. 题目难点在于数据处理 ...

  3. 紫书《算法竞赛入门经典》

    紫书<算法竞赛入门经典>题目一览 第3章 数组和字符串(例题) UVA 272 TEX Quotes UVA 10082 WERTYU UVA 401 Palindromes UVA 34 ...

  4. 线段树/扫描线问卷调查反馈——Rmq Problem / mex(主席树),Boring Queries(二分+st表+主席树),Colorful Squares(扫描线)

    文章目录 Rmq Problem / mex Boring Queries Colorful Squares Rmq Problem / mex luogu4137 对aia_iai​建权值线段树 再 ...

  5. 根据中心点、半径长度和角度画点

    直接上代码: 需要引用 Math 单元. procedure CenterRadiusPoint(const PX, PY: Integer; const Angle: Double;const Ra ...

  6. 舵机任意角度程序_【舵机初动】基于Mind+ Ardunio入门教程10

    点击上方"蘑菇云创造"可以关注我们哦 本项目要接触到舵机.舵机是一种电机,它使用一个反馈系统来控制电机的位置.可以很好掌握电机角度.大多数舵机是可以最大旋转180°的.也有一些能转 ...

  7. halcon中如何生成椭圆_Halcon中关于角度计算和测量拟合的算子详解

    角度计算算子简介 1.计算直线与水平轴之间的夹角 angle_lx( : : Row1, Column1, Row2, Column2 : Angle) 角度计算方式:将直线看作向量(有方向性),以直 ...

  8. Unity3D 角度 弧度 向量

    1.角度 两条相交直线中的任何一条与另一条相叠合时必须转动的量的量度,转动在这两条直线的所在平面上并绕交点进行. 角度是用以量度角的单位,符号为°.一周角分为360等份,每份定义为1度(1°). 之所 ...

  9. OpenCV利用鼠标操作测量角度

    前言 本文介绍一种在OpenCV中定义鼠标事件来进行对两条直线之间夹角的计算以及输出. 一.本文内容 利用OpenCV设置鼠标操作来进行测量角度,基本思路是通过定义鼠标事件得到三角形的三个点的坐标位置 ...

最新文章

  1. VS2010 + Qt5.3.2配置教程
  2. wpservice.exe应用程序错误
  3. mac os系统使用Visual Studio Code打开浏览器查看HTML文件
  4. java中Collections常用方法总结(包括sort,copy,reverse等)
  5. debian ubuntu 记录系统启动信息
  6. 2021跨境电商独立站将喷发式增长?你知道怎样运营独立站吗?
  7. asp.net mvc 压缩html代码,浅谈ASP.NET中MVC 4 的JS/CSS打包压缩功能
  8. 拉格朗日中值定理ξ怎么求_【实力干货】!!!高中数学教材之外的常用定理和公式!!!...
  9. Linux创建与删除用户
  10. 编译原理:CH3 语法分析
  11. 微信 iOS 收款到帐语音提醒开发总结
  12. oracle10g lsnrctl,Oracle 10g Lsnrctl没有反映 无法连接数据库
  13. CSS设计美丽之百合花(小作品)
  14. 工作6年,谈谈我对“算法岗”的理解
  15. synopsys 工具简介
  16. win10 windows文件查找通配符
  17. 2.4G模块NRF24L01调试经验
  18. python import turtle as t_turtle库的学习笔记(python)
  19. 3d建模基础入门教程,3D建模各行业之间的发展趋势
  20. 医学影像数据集和其他数据集们

热门文章

  1. Security Tutorials系列文章第七章:User-Based Authorization(上)
  2. FileWriter和FileReader解析
  3. C++中lib和dll解析
  4. dll 共享_系统DLL查看和检测工具ListDLLs
  5. ERROR manager.SqlManager: Error reading from database: java.sql.SQLException: Streaming result set
  6. SSM整合(配置文件)
  7. SSH框架整合——基于XML配置文件
  8. 百练 Let it Bead
  9. STM32 - 定时器的设定 - 基础-04 - 输出波形控制 - PWM 模式
  10. C++学习心得总结【20181128】