UVa 1388 Graveyard 墓地雕塑

圆上的等距N个点,每个点相距360/N 度,增加M个点后,每个点相距360/(N+m)度,这N个点可顺时针或逆时针移动

每次取移动的最小值即可算出ans

代码:

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<limits.h>
using namespace std;
double min(double x,double y)
{
	return x< y? x: y;
}
int main()
{
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		double d1,d2;
		d1= 360.0 / n;
		d2= 360.0 / (n+m);
		double ans= 0.0;
		for(int i=1,j=1; i< n && j<= n+m; j++)
		{
			double t1,t2,t3;
			t1= i* d1;
			t2= j* d2;
			t3= (j+1)* d2;
			if(t1>= t2 && t1<= t3)
			{
				ans+= min(t1- t2, t3- t1);
				i++;
			}
		}
		ans= ans/360;
		printf("%.4lf\n",ans*10000);
	}
return 0;
}


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值