Rectangle Puzzle CodeForces - 280A

原题链接
考察:计算几何
思路:
??基本参考这位大佬的思路 GO
??如果是情况\(2\)的话,\(v\)就不存在.

Code

#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const double PI = acos(-1);
LL w,h,a;
long double get(long double x) 
{
	if(x<0) x = -x;
	return x;
}
int main()
{
	scanf("%lld%lld%lld",&w,&h,&a);
	if(h>w) swap(h,w);
	if(a==90)
	{
		printf("%.9lf\n",1.0*h*h);
		return 0;
	}
	if(!a||a==180)
	{
		printf("%.9lf\n",1.0*w*h);
		return 0;
	}
	if(a>90) a=180-a;
	long double sina = sin(a*PI/180);
	long double cosa = cos(a*PI/180);
	long double tana = tan(a*PI/180);
	long double z  = (h*sina-w*cosa-w)/(sina*sina-cosa*cosa-2*cosa-1);
	long double v  = (w-z*cosa-z)/sina;
	long double x = z*cosa,y = z*sina;
	long double t = v*sina,u = v*cosa;
	long double ans = w*h-x*y-t*u;
	ans = v<=0?h*h/sina:ans;
	printf("%.9Lf\n",ans);
	return 0;
}

Rectangle Puzzle CodeForces - 280A

上一篇:浅谈 JVM GC 的安全点与安全区域


下一篇:如何用 Downie 自定义模式抓取视频