您的位置:首页 > 其它

Graveyard UVALive - 3708(思维)

2017-04-27 17:21 363 查看
看了大白才会的,大白太厉害了。

思路:在原来n个的基础上再加入m个,肯定有一个是不用变的,这样其他的位置就被确定了,需要移动的就是那些不在整数点上的点,选择近的点移动就好了。

#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int n,m;

int main()
{
while(~scanf("%d%d",&n,&m))
{
double sum = 0;
for(int i=1;i<n;i++)
{
double pos = 1.0*i/n*(n+m);
sum += fabs(pos-floor(pos+0.5))/(n+m);
}
printf("%.4lf\n",sum*10000);
}
return 0;
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: