思维 UVALive 3708 Graveyard

题目传送门

 /*
题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离;
思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000即为距离;
详细解释:http://www.cnblogs.com/zywscq/p/4268556.html
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <queue>
using namespace std; const int MAXN = 1e4 + ;
const int INF = 0x3f3f3f3f; int main(void) //UVALive 3708 Graveyard
{
//freopen ("UVALive_3708.in", "r", stdin); int n, m; while (scanf ("%d%d", &n, &m) == )
{
double ans = 0.0, pos;
for (int i=; i<n; ++i)
{
pos = (double) i / n * (n + m);
ans += fabs (pos - floor (pos + 0.5)) / (n + m);
} printf ("%.4lf\n", ans * );
} return ;
}
上一篇:定时器springMVC


下一篇:【BZOJ1054】[HAOI2008]移动玩具