UVA - 1388 Graveyard 【数学】
生活随笔
收集整理的這篇文章主要介紹了
UVA - 1388 Graveyard 【数学】
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接
題意:
給一個周長為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; }?
?
?
轉載于:https://www.cnblogs.com/cniwoq/p/6770771.html
總結
以上是生活随笔為你收集整理的UVA - 1388 Graveyard 【数学】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 睡觉梦到坟墓是什么意思
- 下一篇: 别人梦到我了是什么意思