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 ...
随机推荐
- 【转】linux驱动开发的经典书籍
原文网址:http://www.cnblogs.com/xmphoenix/archive/2012/03/27/2420044.html Linux驱动学习的最大困惑在于书籍的缺乏,市面上最常见的书 ...
- 锋利的jQuery读书笔记---jQuery中动画
jQuery中的动画: 1.show和hide 2.fadeIn和fadeOut 3.slideUp和slideDown <!DOCTYPE html> <html> < ...
- iOS-利用AFNetworking(AFN 1.x)-实现文件上传
转:http://www.kaifazhe.com/ios_school/380067.html 官方建议AFN的使用方法 1. 定义一个全局的AFHttpClient:包含有 1> baseU ...
- [Everyday Mathematics]20150118
设 $X$ 是线性空间, $\phi_1,\cdots,\phi_n,\phi$ 是 $X$ 上的线性泛函, 试证: $$\bex \phi\in \span\sed{\phi_1,\cdots,\p ...
- golang学习遭遇错误原因分析续
7. error: reference to field ‘Printf’ in object which has no fields or methods f.Printf("%v&quo ...
- 通过SQL进行远程访问
通过SQL语句访问远程数据库 1.得建立链接服务器: --删除链接服务器 if exists(select * from master.dbo.sysservers where isremote=0 ...
- Write a program to convert decimal to 32-bit unsigned binary.
Write a program to convert decimal to 32-bit unsigned binary. Write a program to convert a 32-bit un ...
- My implementation of AVL tree
C++实现的avl平衡树 #include <stdlib.h> #include <time.h> #include <string.h> #include &l ...
- poj2396 Budget(有源汇上下界可行流)
[题目链接] http://poj.org/problem?id=2396 [题意] 知道一个矩阵的行列和,且知道一些格子的限制条件,问一个可行的方案. [思路] 设行为X点,列为Y点,构图:连边(s ...
- 【暑假】[实用数据结构]UVAlive 3135 Argus
UVAlive 3135 Argus Argus Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %l ...