Codeforces Round #172 (Div. 2) C. Rectangle Puzzle 数学题几何
C. Rectangle Puzzle
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/281/problem/C
Description
You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the side that is parallel to the Oxaxis, equals w, the length of the side that is parallel to the Oy axis, equals h. The second rectangle can be obtained by rotating the first rectangle relative to the origin of coordinates by angle α.
Your task is to find the area of the region which belongs to both given rectangles. This region is shaded in the picture.
Input
The first line contains three integers w, h, α (1 ≤ w, h ≤ 106; 0 ≤ α ≤ 180). Angle α is given in degrees.
Output
In a single line print a real number — the area of the region which belongs to both given rectangles.
The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 6.
Sample Input
1 1 45
Sample Output
0.828427125
HINT
题意
给你一个中心在原点的矩形,这个矩形的边平行于坐标轴,然后将这个矩形旋转k°,然后问你旋转之后的矩形和原来的矩形相交的面积是多少
题解:
解方程,有两种情况一种是上图给你的,一种是大正方形减去两个矩形的那种
分别把公式列出来,然后解就好了。。
高中几何题,蛋疼。。
代码
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
const double pi = acos(-1.0);
int main()
{
double w,h,t;cin>>w>>h>>t;
if(w<h)swap(w,h);
if(t>=)t=-t;
t=t*pi/;
double x1,y1,x2,y2;
y2 = (h-tan(t)*w/(+1.0/cos(t)))/(+/cos(t)-tan(t)*tan(t)/(+/cos(t)));
x2 = tan(t)*y2;
y1 = (w-y2*tan(t))/(+/cos(t));
x1 = y1*tan(t); //cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
//cout<<tan(t)<<endl;
if(tan(t/)<h/w)
{
double ans = w*h - x1*y1 - x2*y2;
printf("%.16f\n",ans);
}
else
{
double x = h / sin(t);
printf("%.10f\n",w*h-(w-x)*h);
} }
Codeforces Round #172 (Div. 2) C. Rectangle Puzzle 数学题几何的更多相关文章
- Codeforces Round #172 (Div. 2)
A. Word Capitalization 模拟. B. Nearest Fraction 枚举. C. Rectangle Puzzle 求出两个矩形的点,套简单多边形的面积交板子. D. Max ...
- Codeforces Round #172 (Div. 1 + Div. 2)
A. Word Capitalization 模拟. B. Nearest Fraction 枚举. C. Rectangle Puzzle 求出两个矩形的点,套简单多边形的面积交板子. D. Max ...
- Codeforces Round #172 (Div. 2) B. Nearest Fraction 二分
B. Nearest Fraction Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/281/p ...
- Codeforces Round #467 (Div. 2) E -Lock Puzzle
Lock Puzzle 题目大意:给你两个字符串一个s,一个t,长度<=2000,要求你进行小于等于6100次的shift操作,将s变成t, shift(x)表示将字符串的最后x个字符翻转后放到 ...
- codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)
题目链接:http://www.codeforces.com/problemset/problem/281/A题意:将一个英文字母的首字母变成大写,然后输出.C++代码: #include <c ...
- Codeforces Round #172 (Div. 2) D. Maximum Xor Secondary 单调栈应用
http://codeforces.com/contest/281/problem/D 要求找出一个区间,使得区间内第一大的数和第二大的数异或值最大. 首先维护一个单调递减的栈,对于每个新元素a[i] ...
- Codeforces Round #467 (Div. 1). C - Lock Puzzle
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> ...
- Codeforces Round #295 (Div. 2)C - DNA Alignment 数学题
C. DNA Alignment time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(分形)
E. Dasha and Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
随机推荐
- 多线程程序设计学习(3)immutable pattern模式
Immutable pattern[坚不可摧模式] 一:immutable pattern的参与者--->immutable(不变的)参与者 1.1:immutable参与者是一个 ...
- Java基础——I/O续
目录 二进制I/O类 文件导航和I/O 二进制I/O类 FileInputStream类和FileOutputStream类 *FileOutputStream(file: File) *FileOu ...
- CSS的伪元素(二)
随便聊聊CSS的伪元素,虽然它们在项目开发中用的并不多,但确实很有用,在项目中不用它,是因为大家不能了解它们,下面是一个工作场景,如有四个按钮,分别是建立,编辑,删除和修改,而我们要求这在前台显示的汉 ...
- MOSS 2010:Visual Studio 2010开发体验(14)——列表开发之事件接收器
转:http://boke.25k5.com/kan141919.html 通过前面几篇,我们已经完成了内容类型,列表定义,列表实例g 8h"@的开发.本篇继续讲解列表中的一个重要环节- ...
- echo二次开发 ecshop 函数列表
lib_time.php (时间函数) gmtime() P: 获得当前格林威治时间的时间戳 /$0 server_timezone() P: 获得服务器的时区 /$0 local_mktime($h ...
- 应用市场高速下载以及网页端调起APP页面研究与实现
Github博文地址,此处更新可能不是很及时. 好久没写博客了,好大一个坑.正好,最近刚做完应用市场的高速下载功能,便拿来填了这个坑. 话说产品为了增加用户量,提升用户活跃度以及配合推广,更坑爹的是看 ...
- POJ 1064 Cable master
Cable master Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 37865 Accepted: 8051 Des ...
- HDU 4638-Group(线段树+离线处理)
题意: 给n个编号,m个查询每个查询l,r,求下标区间[l,r]中能分成标号连续的组数(一组内的标号是连续的) 分析: 我们认为初始,每个标号为一个组(线段树维护区间组数),从左向右扫序列,当前标号, ...
- web安全测试&渗透测试之sql注入~~
渗透测试概念: 详见百度百科 http://baike.baidu.com/link?url=T3avJhH3_MunEIk9fPzEX5hcSv2IqQlhAfokBzAG4M1CztQrSbwsR ...
- 【JSONCpp】简介及demo
一.JSON简介 JSON 一种轻量级的数据交换格式,易于阅读.编写.解析,全称为JavsScript ObjectNotation. JSON由两种基本结构组成 ① 名字/值 对的集合,可以理解 ...