ZJU 3733 长沙现场赛 H Skycity

这题做的我真是李菊福了

下午做重现的时候一直调不出样例

晚上拉到自己电脑上一跑立马出了样例   哭翔

晚上看了个哥们用二分过的

其实可以不用二分,直接int count = (int )(2*PI/(最小长度对应当前半径的角度))

因为强制转换丢掉了小数部分(余数)

所以就可以得到最多count边形   (再多边长就会小于最小长度了)


最后int cnt=(int )(fullang/angle+eps);//去掉eps就过了  真是菊服

点击打开链接

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;
double R,r,H,F,S;

const double eps= 1e-9;
const double fullang=2*acos(-1.0);

int dcmp(double x){
	if(fabs(x) < eps) return 0; else return x<0? -1:1;
}

int main(){
	while(scanf("%lf%lf%lf%lf%lf",&R,&r,&H,&F,&S)!=EOF){
			double h=H/F;
			double add=(R-r)/F;
			double minl=S/h;
			double cur=r;
			double ans=0;
			
			while(dcmp(cur-R)!=0){
					double angle=atan(minl/2/cur)*2;
					int cnt=(int )(fullang/angle);
					double len= tan(fullang/cnt/2) * cur;
					ans+=len*cnt*2;
					cur+=add;

			}
			ans*=h;
			printf("%.3lf\n",ans);
	}
	return 0;
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值