题意:有n个正方形和一个角(均在第一象限中),使这些正方形与这个角构成封闭的阴影区域,求阴影区域面积的最大值。

析:很容易知道只有所有的正方形的对角形在一条直线时,是最大的,然后根据数学关系,就容易得到答案。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define print(a) printf("%d\n", (a))
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e3 + 5;
const int mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
} int main(){
double sq, s, ax, ay, bx, by;
while(scanf("%d", &n) && n){
cin >> ax >> ay >> bx >> by;
sq = 0.0, s = 0.0;
for(int i = 0; i < n; i++){
double m; cin >> m;
s += m * m;
sq += m;
}
double k1 = ay / ax, k2 = by / bx;
double x1 = fabs((k2+1)*sq/(k2-k1)), y1 = k1*x1;
double x2 = fabs((k1+1)*sq/(k2-k1)), y2 = k2*x2;
double area = fabs((x1*y2 - x2*y1) / 2.0);
double sum = area - s/2.0;
printf("%.3lf\n", sum);
}
return 0;
}

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

  1. UVa 1643 Angle and Squares

    题意: 如图,有n个正方形和一个角(均在第一象限中),使这些正方形与这个角构成封闭的阴影区域,求阴影区域面积的最大值. 分析: 直观上来看,当这n个正方形的对角线在一条直线上时,封闭区域的面积最大.( ...

  2. UVA - 1643 Angle and Squares (角度和正方形)(几何)

    题意:第一象限里有一个角,把n(n <= 10)个给定边长的正方形摆在这个角里(角度任意),使得阴影部分面积尽量大. 分析:当n个正方形的对角线在一条直线上时,阴影部分面积最大. 1.通过给定的 ...

  3. 紫书 习题 10-3 UVa 1643(计算几何 叉乘)

    直观感觉对角线重合的时候面积最大 然后可以根据方程和割补算出阴影部分的面积 注意知道两点坐标,可以求出与原点形成的三角形的面积 用叉乘,叉乘的几何意义以这两个向量为边的平行四边形的面积 所以用叉乘除以 ...

  4. UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)

    Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...

  5. uva 10652 Board Wrapping (计算几何-凸包)

    Problem B Board Wrapping Input: standard input Output: standard output Time Limit: 2 seconds The sma ...

  6. poj3347 Kadj Squares (计算几何)

    D - Kadj Squares Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Su ...

  7. UVA 11178 Morley's Theorem 计算几何模板

    题意:训练指南259页 #include <iostream> #include <cstdio> #include <cstring> #include < ...

  8. UVA 11178 Morley's Theorem (计算几何)

    题目链接 lrj训练指南 P259 //==================================================================== Point getP( ...

  9. [POJ2002]Squares(计算几何,二分)

    题目链接:http://poj.org/problem?id=2002 给定一堆点,求这些点里哪些点可以构成正方形,题目给定n<=1000,直接枚举四个点是肯定会超时的,因此要做一些优化. 有公 ...

随机推荐

  1. google 集群计算的3大基础设施

    1.  GFS  分布式文件系统 2.  map-reduce 分布式计算框架 3. bigtable 海量key-value的存储 (开源实现:Hypertable)

  2. 关于文件与文件系统的压缩与打包命令-Linux(笔记)

    1.gzip : 压缩命令 gzip [-cdtv#] 文件名称 (后缀为.gz) -c :将压缩的数据输出到屏幕上,可通过数据流重定向处理 -d : 解压缩的參数 -v : 能够显示源文件/压缩文件 ...

  3. Linux bridge-utils tunctl 使用

    网络 brctl是Linux下用来管理以太网桥.在内核中建立.维护.检查网桥配置的命令 STP - Spanning Tree Protocol(生成树协议)逻辑上断开环路.防止二层网络的广播风暴的产 ...

  4. Codeforces 486E LIS of Sequence(线段树+LIS)

    题目链接:Codeforces 486E LIS of Sequence 题目大意:给定一个数组.如今要确定每一个位置上的数属于哪一种类型. 解题思路:先求出每一个位置选的情况下的最长LIS,由于開始 ...

  5. JAVA BigDecimal 高精度运算

    文章参考一位博友,由于时间太久忘了链接,见谅! public class BigDecimalUtils { private static final int DIV_SCALE = 10;// 除法 ...

  6. RabbitMQ/pika模块

    简介 MessageQueue用于解决跨进程.跨线程.跨应用.跨网络的通信问题. RabbitMQ使用erlang开发,在windows上使用时要先安装erlang. 官方的示例比较容易理解,可以点这 ...

  7. YTUOJ-推断字符串是否为回文

    题目描写叙述 编敲代码,推断输入的一个字符串是否为回文.若是则输出"Yes",否则输出"No".所谓回文是指順读和倒读都是一样的字符串. 输入 输出 例子输入 ...

  8. scala进阶笔记:函数组合器(combinator)

    collection基础参见之前的博文scala快速学习(二). 本文主要是组合器(combinator),因为在实际中发现很有用.主要参考:http://www.importnew.com/3673 ...

  9. Linux epoll 源码注释

    https://www.cnblogs.com/stonehat/p/8613505.html 这篇文章值得好好读,先留个记录,回头看. IO多路复用之epoll总结 - Anker's Blog - ...

  10. JSP 用poi 读取Excel

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...