时间限制 1000 ms 内存限制 65536 KB
作为一个东北大老爷们,大A熊以力气大著称,现在有一颗半径为r的树,剖面图如黑色的圆,大A熊决定搬几个半径为R的圆柱形桶将其围住,剖面图如红色和绿色的圆
如图,大A熊必须用7个半径为r的桶能被围住,他的树。
hint:
double转换int可以这样: x=(int)y;这种方式是下取整的。
输入输出很大,cin cout 会造成超过时间限制,请使用scanf输入和printf输出,控制符可以用 "%lf" 。
you may use those function
cosCompute cosine (function )sinCompute sine (function )tanCompute tangent (function )acosCompute arc cosine (function )asinCompute arc sine (function )atanCompute arc tangent (function )atan2Compute arc tangent with two parameters (function )
coshCompute hyperbolic cosine (function )sinhCompute hyperbolic sine (function )tanhCompute hyperbolic tangent (function )acosh Compute arc hyperbolic cosine (function )asinh Compute arc hyperbolic sine (function )atanh Compute arc hyperbolic tangent (function )
数据由多组输入组成,EOF结束。
每组数据一行,包含两个数
每组输出占一行,表示大A熊最少需要放置的桶的个数。
3.0 3.0
3.0 2.9
6
7
由几何关系可得,
R/(R+r)=sinθ
θ=2π/(2*n)=π/n
所以n=π/arcsin(R/(R+r)),并且向上取整。
然后在转换成整数输出n。
#include<cstdio>
#include<cmath>
#define ll long long
#define dd double
const dd PI=acos(-1.0);
dd r,R,n;
ll ans;
int main()
{
while(~scanf("%lf%lf",&r,&R))
{
n=ceil(PI/asin(R/(R+r)));
ans=(ll)n;
printf("%ld\n",ans);
}
return 0;
}