题目链接
题意:
给一个周长为10000的圆,一开始有n个距离相等的点, 现在要添加m个点使其仍旧保持距离相等的状态,问最小的移动距离。
思路:
遍历原来的每一个点,找出离他最近的新的位置。
#include <map> #include <set> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <iostream> #include <stack> #include <cmath> #include <string> #include <vector> #include <cstdlib> //#include <bits/stdc++.h> //#define LOACL #define space " " using namespace std; //typedef long long LL; typedef __int64 Int; typedef pair<int, int> paii; const int INF = 0x3f3f3f3f; const double ESP = 1e-5; const double PI = acos(-1.0); const int MAXN = 100 + 10; int main() {int n, m;while (scanf("%d%d", &n, &m) != EOF) {double ans = 0;double l = 360.0/(n + m);for (int i = 0; i < n; i++) {double temp = 360.0/n * i;double x = temp/l;ans += min(abs(temp - x*l), abs(x*l+l-temp))/360.0*100;}printf("%.6lf\n", ans);}return 0; }