Links: http://acm.hust.edu.cn/vjudge/problem/15133
Analysis: Too good, first the circumference of the circle as 1, evenly distributed n points, and then add m points after a total of (n+m) points, then we put the circumference of the circle to enlarge (n+m), so what good? Is (n+m) the coordinates of a sculpture are all integral points, the corresponding original in the circumference of 1 n points of coordinates from the i/n method (n+m) times, because the sculpture position to move is an integer so we can use rounding to find the nearest whole point (target sculpture position), and then the side length reduced back to 1, In the case of a side length of 1, n sculptures move to the distance of the nearest target sculpture position, the distance of the n-1 point (the No. 0 point does not move) is accumulated and then the distance and equal proportion are enlarged by 10000.
1#include <cstdio>2#include <cmath>3 using namespacestd;4 5 intMain () {6 intN, M;7 while(SCANF ("%d%d", &n, &m) = =2) {8 DoubleAns =0.0;9 for(inti =1; I < n; i++) {Ten Doublepos = (Double) I * (n + m)/N; OneAns + = Fabs (Pos-floor (pos +0.5))/(n +m); A } -printf"%.4lf\n", ans *10000); - } the return 0; -}
UVa3708 Graveyard (coordinate scaling)