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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值