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 ...
随机推荐
- Java-泛型编程-使用通配符? extends 和 ? super
原文地址:http://blog.csdn.net/fw0124/article/details/42296283 泛型中使用通配符有两种形式:子类型限定<? extends xxx>和超 ...
- Entity Framework中编辑时错误ObjectStateManager 中已存在具有同一键的对象
ObjectStateManager 中已存在具有同一键的对象.ObjectStateManager 无法跟踪具有相同键的多个对象. 说明: 执行当前 Web 请求期间,出现未经处理的异常.请检查堆栈 ...
- metadata lock
1 锁等待的例子 session 1: 执行查询但不提交 mysql> begin; mysql> select * from test where c2 = '1'; session 2 ...
- JS 代码编一个倒时器
有时候在生活中,你需要一个JavaScript倒计时时钟,而不是一个末日装置设备.不管你是否有一次约会,销售.促销.或者游戏,你可以受益于使用原生JavaScript构建一个时钟,而不是拿到一个现成的 ...
- MyBatis 入门到精通(二) SQL语句映射XML文件
MyBatis 真正强大之处就在这些映射语句,也就是它的魔力所在.对于它的强大功能,SQL 映射文件的配置却非常简单. 如果您比较SQL 映射文件配置与JDBC 代码,您很快可以发现,使用SQL 映射 ...
- 【LeetCode 160】Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- 将 Sublime 3 打造成 Python/Django IDE
Sublime Text 是一款非常强大的文本编辑器, 下面我们介绍如何将 Sublime Text 3 打造成一款 Python/Django 开发利器: 1. 安装 Sublime Text 3 ...
- Tkinter教程之Event篇(3)
本文转载自:http://blog.csdn.net/jcodeer/article/details/1823550 '''Tkinter教程之Event篇(3)''''''11.两个事件同时绑定到一 ...
- Google AppEngine 创建的例子
1.guestbook: http://chenyy-gac-test.appspot.com/ 2.time clock: http://chenyy-gac-20150922.appspot.co ...
- hive优化之------控制hive任务中的map数和reduce数
一. 控制hive任务中的map数: 1. 通常情况下,作业会通过input的目录产生一个或者多个map任务. 主要的决定因素有: input的文件总个数,input的文件大小,集群设置的 ...