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 Ox axis, 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.

Examples

Input

1 1 45

Output

0.828427125

Input

6 4 30

Output

19.668384925

Note

The second sample has been drawn on the picture above.

思路:

根据对称性,

我们把矩阵转化为w>=h 形状的。

又根据对称性,

如果角度a是钝角,可以把a变为与a互补的锐角,不影响答案值。

如图所示,我们只需要三角形1和2的面积就可以求的阴影部分面积,

那么根据绿色的线我们可以得出

x+z+t=w

根据紫色的线我们可以的出:

y+v+u=h

而根据三角形关系

我们可以得到 x,y与z的关系,u,t与v的关系。

两个方程,两个未知量(z,v)可以求出z和v,从而可以得出答案。

还有一个需要特殊判断的情况是:

这种阴影部分的面积是一个蓝色的菱形,那么我们根据粉红色区域的三角形关系可以的出答案。

细节见代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) {ll ans = 1; while (b) {if (b % 2) { ans = ans * a % MOD; } a = a * a % MOD; b /= 2;} return ans;}
inline void getInt(int *p);
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
typedef long double ld;
ld w, h, a;
const ld pi = acos(-1);
int main()
{
//freopen("D:\\code\\text\\input.txt","r",stdin);
//freopen("D:\\code\\text\\output.txt","w",stdout);
cin >> w >> h >> a;
if (h > w) {
swap(h, w);
}
a = min(a, 180.0 - a);
a /= 180;
a *= pi;
ld z = (w - (h * sin(a)) / (1.0 + cos(a))) / (1.0 + cos(a) - sin(a) * sin(a) / (1 + cos(a)));
ld v = (h - z * sin(a)) / (1.0 + cos(a));
if (v > 0.0) {
ld x = z * cos(a);
ld y = z * sin(a);
ld ans = w * h;
ans -= x * y;
x = v * cos(a);
y = v * sin(a);
ans -= x * y;
cout << fixed << setprecision(7) << ans << endl;
} else {
v = h / sin(a);
ld x = v * cos(a / 2.0);
ld y = v * sin(a / 2.0);
ld ans = x * y * 2.0;
cout << fixed << setprecision(7) << ans << endl;
} return 0;
} inline void getInt(int *p)
{
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {
*p = *p * 10 - ch + '0';
}
} else {
*p = ch - '0';
while ((ch = getchar()) >= '0' && ch <= '9') {
*p = *p * 10 + ch - '0';
}
}
}

Rectangle Puzzle CodeForces - 281C (几何)的更多相关文章

  1. Codeforces Round #172 (Div. 2) C. Rectangle Puzzle 数学题几何

    C. Rectangle Puzzle Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/281/p ...

  2. Bash and a Tough Math Puzzle CodeForces 914D 线段树+gcd数论

    Bash and a Tough Math Puzzle CodeForces 914D 线段树+gcd数论 题意 给你一段数,然后小明去猜某一区间内的gcd,这里不一定是准确值,如果在这个区间内改变 ...

  3. CodeForces 303B Rectangle Puzzle II

    题意: 给定一个靠着坐标轴长为n,宽为m的矩形和 矩形中的一个点A,求在这个矩形内部一个 长宽比为a/b的小矩形,使这个小矩形的长宽尽量大使点A在小矩形内部,并且点A尽量靠近小矩形的中心 CF的思维题 ...

  4. An overnight dance in discotheque CodeForces - 814D (几何)

    大意: 给定n个不相交的圆, 求将n个圆划分成两部分, 使得阴影部分面积最大. 贪心, 考虑每个连通块, 最外层大圆分成一部分, 剩余分成一部分一定最优. #include <iostream& ...

  5. Bash and a Tough Math Puzzle CodeForces - 914D (线段树二分)

    大意:给定序列, 单点修改, 区间询问$[l,r]$内修改至多一个数后$gcd$能否为$x$ 这题比较有意思了, 要注意到询问等价于$[l,r]$内最多有1个数不为$x$的倍数 可以用线段树维护gcd ...

  6. [CodeForces]CodeForces 13D 几何 思维

    大致题意: 给出N个红点和M个蓝点,问可以有多少个红点构成的三角形,其内部不含有蓝点 假设我们现在枚举了一条线段(p[i],p[j]),我们可以记录线段下方满足(min(p[i].x,p[j].x)& ...

  7. Lock Puzzle CodeForces - 936C (构造)

    大意: 给定字符串$s$,$t$, 每次操作可以将$S=AB$变为$S=B^RA$, 要求$3n$次操作内将$s$变为$t$. #include <iostream> #include & ...

  8. CodeForces - 849B 几何

    题意:给n个点,问是否能两条平行线覆盖所有的点 思路:因为要求全部覆盖,所以我们第一个点肯定是会入其中一条直线,其实只用判前三个点的所有情况即可 #include<stdio.h> #in ...

  9. B - Bash and a Tough Math Puzzle CodeForces - 914D (线段树的巧妙应用)

    题目大意:当输入2时,将p处的点的值修改为x, 当输入1时,判断区间[L,R]的gcd是否几乎正确,几乎正确的定义是最多修改一个数,使得区间[L,R]的gcd为x. 题解:用线段树维护一个gcd数组, ...

随机推荐

  1. CISC和RISC的区别

    转载于http://blog.sina.com.cn/s/blog_9d5430ce0100x5pb.html RISC(Reduced Instruction Set Computer)和CISC( ...

  2. Windows Server 2019安装OpenSSH Server简明教程

    Windows Server 2019安装OpenSSH Server简明教程   Windows Server 2019内置OpenSSH Server组件了.只不过OpenSSH Server默认 ...

  3. JAVA语言课堂测试01源代码(学生成绩管理系统)

    package 考试; /*信1807-8 * 20183798 * 向瑜 */ import java.util.Scanner; //ScoreInformation 类 class ScoreI ...

  4. 【VS开发】VS2010中导入ActiveX控件

    方法1: 1.首先在在项目上面右击添加类,如下图所示: 2.点击添加ActiveX控件中的MFC类 3.找到需要添加的ActiveX类. 4.点击完成即可. 5.此时转到资源视图,打开如下视图.可能工 ...

  5. eclipse Maven Bootstrap 导航栏

    1.在pom.xml添加两个依赖 Bootstrap 依赖和jQuery依赖 代码如下 <!-- https://mvnrepository.com/artifact/org.webjars/b ...

  6. python-第五章习题

    5.2 def isOdd(x): if(x%2==0): return False return True x=eval(input("")) print(isOdd(x)) 5 ...

  7. 基于SpringBoot从零构建博客网站 - 整合ehcache和开发注册登录功能

    对于程序中一些字典信息.配置信息应该在程序启动时加载到缓存中,用时先到缓存中取,如果没有命中,再到数据库中获取同时放到缓存中,这样做可以减轻数据库层的压力.目前暂时先整合ehcache缓存,同时预留了 ...

  8. 第一次入坑docker

    直接进入主题 1.首先获取git clone项目 2.创建镜像:docker build -t="docker" .(注意千万不要忘了.) 3.列出镜像:docker images ...

  9. springboot2.0application.在yml文件中添加自定义配置

    1. 在application.yml文件中添加自定义配置 app: platform: version: code: '1.0.0' 2. 定义bean类   具体格式: 其中的成员变量名称需要与配 ...

  10. MyBatis学习存档(2)——核心配置文件

    一.xml节点结构 configuration为根节点 properties 可以配置在Java 属性配置文件中 settings 修改 MyBatis 在运行时的行为方式 typeAliases 为 ...