题意:
在一个具有n个等距建筑的圆形中插入m个,使得保持等距,求最短移动距离;
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
int n, m;
double tol = 10000;
int main()
{
while (scanf("%d%d", &n, &m) != EOF)
{
double ans = 0;
for (int i = 1; i < n; i++)
{
double pos = (double)i / n*(n + m);
ans += fabs(pos- floor(pos+0.5) )/ (n + m);
}
printf("%.4lf\n",ans*tol);
}
return 0;
}