题意:周长为10000的圆上等距分布n个雕塑,求再加入m个雕塑后,为使所有雕塑等距分布所需移动原来n个雕塑的最小总距离。

分析:计算相对距离。

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<algorithm>
#include<set>
#include<stack>
#include<list>
#include<map>
#include<queue>
#include<deque>
#include<vector>
#include<cctype>
using namespace std;
const int MAXN = + ;
const int MAXT = + ;
const int INF = 0x7f7f7f7f;
const double EPS = 1e-;
const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long llu;
int main()
{
int n, m;
while(scanf("%d%d", &n, &m) != EOF)
{
double ans = ;
for(int i = ; i < n; ++i)
{
double tmp = (double)i / n * (n + m);//所有待移动雕塑在n+m的等距分布里的坐标
ans += fabs(tmp - floor(tmp + 0.5)) / (n + m);//除以n+m,是使ans的结果是以总长度为1为基准,而不是n+m
}
printf("%.4lf\n", ans * );
}
return ;
}

UVaLive 3708的更多相关文章

  1. 思维 UVALive 3708 Graveyard

    题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...

  2. UVALive.3708 Graveyard (思维题)

    UVALive.3708 Graveyard (思维题) 题意分析 这标题真悲伤,墓地. 在周长为1e4的圆周上等距分布着n个雕塑,现在要加入进来m个雕塑,最终还要使得这n+m个雕塑等距,那么原来的n ...

  3. uvalive 3708 Graveyard

    https://vjudge.net/problem/UVALive-3708 题意: 一个长度为10000的圆环上放着n个雕塑,每个雕塑之间的距离均相等,即这个圆环被n个点均分.现在需要加入m个雕塑 ...

  4. UVAlive 3708 Graveyard(最优化问题)

    题目描述: 在周长10000的圆上,初始等距的放置着n个雕塑,现在新加入m个雕塑,要使得这n+m个雕塑仍然等距,问原来n个雕塑要移动的距离总和的最小值. 原题地址: http://acm.hust.e ...

  5. UVALive 3708 Graveyard(思维题)

    将原有的每个雕塑的坐标位置,映射在一个总长为n+m的数轴上,设第一个点的坐标为0,(新的等分点必然有至少有一个和原来n等分的等分点重合,因为等分点可以等距的绕圆周旋转,总可以转到有至少一个重合的,不妨 ...

  6. 2015Summer Training #2

    暑假集训昨天刚开始,14级的小伙伴快到齐了,hhhhh ,毕竟下学期区域赛,对我们来说还是很困难的. 打算每天写份总结. UVA 11300 C.Spreading the Wealth 题目大意:n ...

  7. UVALive - 4108 SKYLINE[线段树]

    UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug ...

  8. UVALive - 3942 Remember the Word[树状数组]

    UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...

  9. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

随机推荐

  1. 几种server模型

    TCP測试用客户程序 每次执行客户程序,在命令行參数指定server的ip地址,port,发起连接的子进程数,和一个待发送的字符串数据,客户程序将模拟多个客户依据指定的子进程数创建子进程来并发的连接到 ...

  2. iOS开发——网络编程Swift篇&(八)SwiftyJSON详解

    SwiftyJSON详解 最近看了一些网络请求的例子,发现Swift在解析JSON数据时特别别扭,总是要写一大堆的downcast(as?)和可选(Optional),看?号都看花了.随后发现了这个库 ...

  3. php的分表分库类

    <?php include 'config.php'; class Model{ //用户名 protected $user; //密码 protected $pwd; //主机 protect ...

  4. MySQL Router 测试使用 转

    MySQL Router 测试使用 . 特性 MySQL Router 并没有包括一些特别新的特性, 总体上看中规中矩, 不过 first-available 和插件两个特性挺有意思, 后续会进行讲解 ...

  5. Objective-C语法之NSArray和NSMutableArray

    转自:http://www.cnblogs.com/stoic/archive/2012/07/09/2582773.html Objective-C的数组比C++,Java的数组强大在于,NSArr ...

  6. Codeblocks支持C++11

    Setting->Compiler 直接在“Have g++ follow the C++11 ISO C++ language standard [-std=c++11]” 选项上打勾 保存就 ...

  7. PAT 1018

    1018. Public Bike Management (30) There is a public bike service in Hangzhou City which provides gre ...

  8. c语言指针函数与函数指针

    例一:指针函数 指针函数是指带指针的函数,即本质是一个函数.函数返回类型是某一类型的指针 类型标识符    *函数名(参数表) int *f(x,y); 首先它是一个函数,只不过这个函数的返回值是一个 ...

  9. Storm中的LocalState 代码解析

    官方的解释这个类为: /** * A simple, durable, atomic K/V database. *Very inefficient*, should only be * used f ...

  10. Android(java)学习笔记109:通过反射获取成员变量和成员方法并且使用

    一.反射获取成员变量并且使用: 1.获取字节码文件对象:         Class c = Class.forName("cn.itcast_01.Person"); 2.使用无 ...