UVaLive 3708
题意:周长为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的更多相关文章
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive.3708 Graveyard (思维题)
UVALive.3708 Graveyard (思维题) 题意分析 这标题真悲伤,墓地. 在周长为1e4的圆周上等距分布着n个雕塑,现在要加入进来m个雕塑,最终还要使得这n+m个雕塑等距,那么原来的n ...
- uvalive 3708 Graveyard
https://vjudge.net/problem/UVALive-3708 题意: 一个长度为10000的圆环上放着n个雕塑,每个雕塑之间的距离均相等,即这个圆环被n个点均分.现在需要加入m个雕塑 ...
- UVAlive 3708 Graveyard(最优化问题)
题目描述: 在周长10000的圆上,初始等距的放置着n个雕塑,现在新加入m个雕塑,要使得这n+m个雕塑仍然等距,问原来n个雕塑要移动的距离总和的最小值. 原题地址: http://acm.hust.e ...
- UVALive 3708 Graveyard(思维题)
将原有的每个雕塑的坐标位置,映射在一个总长为n+m的数轴上,设第一个点的坐标为0,(新的等分点必然有至少有一个和原来n等分的等分点重合,因为等分点可以等距的绕圆周旋转,总可以转到有至少一个重合的,不妨 ...
- 2015Summer Training #2
暑假集训昨天刚开始,14级的小伙伴快到齐了,hhhhh ,毕竟下学期区域赛,对我们来说还是很困难的. 打算每天写份总结. UVA 11300 C.Spreading the Wealth 题目大意:n ...
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
随机推荐
- ZJU-PAT 1065. A+B and C (64bit) (20)
Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C. Input S ...
- Anroid自定义RatingBar,显示半个(小数个)的stepSize时,变为整数个的问题
<RatingBar android:id="@+id/rb_starbar" style="@style/joblist_item_ratingbar_style ...
- Android-WizardPager
https://github.com/HeinrichReimer/Android-WizardPager
- 以C#编写的Socket服务器的Android手机聊天室Demo
内容摘要 1.程序架构 2.通信协议 3.服务器源代码 4.客户端源代码 5.运行效果 一.程序架构 在开发一个聊天室程序时,我们可以使用Socket.Remoting.WCF这些具有双向通信的协议或 ...
- 算法入门系列一--DP初步
数字三角形(数塔问题) 其实动态规划本身并不是一个特定的算法,是一种用途广泛的问题求解方法,一种思想,一种手段. 1.1问题描述与状态定义 有一个有非负整数组成的三角形,第一行一个数字,下面各行除了最 ...
- mysql 支持emoji
1.修改my.cnf [client] default-character-set = utf8mb4 [mysqld] collation-server = utf8mb4_unicode_ci c ...
- Android(java)学习笔记106-2:反射机制
1.反射机制: JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信息以及动态调用对象的方法的功能称为 ...
- WdatePicker时间控件联动选择
$("#txtStartTime").bind("click focus", function () { var endtimeTf = $dp.$('txtE ...
- avoid null value in field
Each bean should implements 'InitializingBean'
- MPMoviePlayerController过期导致视频播放时间条颠倒及AVPlayerViewController的用法
MPMoviePlayerController虽然好用 但是过期了 所以可能会导致一些莫名的问题 ,比如说下面时间条的问题 但我们可以使用AVPlayerViewController来实现相应的想过 ...