1011: [HNOI2008]遥远的行星
1011: [HNOI2008]遥远的行星
Time Limit: 10 Sec Memory Limit: 162 MBSec Special Judge
Submit: 2241 Solved: 793
[Submit][Status]
Description
直线上N颗行星,X=i处有行星i,行星J受到行星I的作用力,当且仅当i<=AJ.此时J受到作用力的大小为 Fi->j=Mi*Mj/(j-i) 其中A为很小的常量,故直观上说每颗行星都只受到距离遥远的行星的作用。请计算每颗行星的受力,只要结果的相对误差不超过5%即可.
Input
第一行两个整数N和A. 1<=N<=10^5.0.01< a < =0.35
接下来N行输入N个行星的质量Mi,保证0<=Mi<=10^7
Output
N行,依次输出各行星的受力情况
Sample Input
3
5
6
2
4
Sample Output
0.000000
0.000000
1.968750
2.976000
HINT
精确结果应该为0 0 0 2 3,但样例输出的结果误差不超过5%,也算对
Source
设f[i]为第i个行星受到的引力,g[i]表示第i个行星所受引力的最后来源行星
然后小范围(我是取 α * i < 9)暴力搞,大范围就乱搞,忽略除数(i - j)的差距
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ const st=;
var
i,j,k,l,m,n:longint;
p:extended;
b,c:array[..] of longint;
a:array[..] of extended;
begin
readln(n,p);
for i:= to n do read(b[i]);
readln;
for i:= to n do c[i]:=trunc(i*p);
for i:= to n do
begin
if a[i]<> then a[i]:=;
if c[i]<> then
begin
if i<=st then
begin
for j:= to c[i] do a[i]:=a[i]+b[j]/(i-j);
a[i]:=a[i]*b[i];
end
else
begin
a[i]:=(a[i-st]/b[i-st])*((i-st-(c[i-st]/))/(i-(c[i-st]/)));
for j:=c[i-st]+ to c[i] do a[i]:=a[i]+b[j]/(i-j);
a[i]:=a[i]*b[i];
end;
end;
end;
for i:= to n do writeln(a[i]::);
readln;
end.
1011: [HNOI2008]遥远的行星的更多相关文章
- BZOJ 1011 [HNOI2008]遥远的行星
1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 2559 Solved ...
- BZOJ 1011 [HNOI2008]遥远的行星 (误差分析)
1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 4974 Solved ...
- 【BZOJ】1011: [HNOI2008]遥远的行星(近似)
http://www.lydsy.com/JudgeOnline/problem.php?id=1011 题意:$f[i] = \sum_{j=1}^{i-1} \frac{M[i]M[j]}{i-j ...
- [BZOJ 1011] [HNOI2008] 遥远的行星 【近似解】
题目链接: BZOJ - 1011 题目分析 这道题的特别之处在于,答案可以有5%的误差. 嗯..So? 我还是不会,于是看题解. 神犇的题解就是利用这误差范围求一个近似解. 怎么求近似解呢?假如 g ...
- BZOJ.1011.[HNOI2008]遥远的行星(思路 枚举)
题目链接 设当前为\(i\),令\(j=\lfloor a*i\rfloor\),\(1\sim j\) 即为对\(i\)有贡献的行星,这一区间的答案应为\[f[i]=M_i*\sum_{k=1}^j ...
- bzoj1011 [HNOI2008]遥远的行星
1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 2480 Solved ...
- 【bzoj1011】[HNOI2008]遥远的行星
1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 3711 Solved ...
- BZOJ1011 [HNOI2008]遥远的行星 【奇技淫巧】
1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec Memory Limit: 162 MBSec Special Judge Submit: 5058 Solve ...
- [HNOI2008]遥远的行星
题目描述 直线上N颗行星,X=i处有行星i,行星J受到行星I的作用力,当且仅当i<=AJ.此时J受到作用力的大小为 Fi->j=Mi*Mj/(j-i) 其中A为很小的常量,故直观上说每颗行 ...
随机推荐
- Apache的.htaccess到Nginx的转换
今天项目要求从Apache转到Nginx,遇到了要将原来的rewrite规则移过来的问题,找了半天资源,居然有一个转换工具,地址如下: http://www.anilcetin.com/convert ...
- 字符串的长度超过了为 maxJsonLength 属性设置的值
当出现类似标题的错误时,可以按照如下方法解决: 1. 检查是否传递的JSON字符串长度过长 2.增加JSON串的长度设置,设置如下: <system.web.extensions> ...
- Spring context:component-scan代替context:annotation-config
Spring context:component-scan代替context:annotation-config XML: <?xml version="1.0" encod ...
- request.setAttribute和request.getAttribute还有session.setAttribute和session.getAttribute还有request.getParameter和request.getAttribute区别和联系
1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...
- mac下sublime 配置查看源码
sublime及package control的安装查看之前一篇文章:http://www.cnblogs.com/xdwa/p/5805101.html 安装ctags 安装完毕package co ...
- HDU1392(凸包)
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- Windows下Python读取GRIB数据
之前写了一篇<基于Python的GRIB数据可视化>的文章,好多博友在评论里问我Windows系统下如何读取GRIB数据,在这里我做一下说明. 一.在Windows下Python为什么无法 ...
- ubuntu下编译java程序
ubuntu下编译java程序 首先需要安装jdk,并配置好相应环境变量 下面以简单的HelloWorld为例 文件名为HelloWorld.java java代码: public class Hel ...
- ubuntu linux 设置环境变量
添加环境变量 1.添加临时变量 终端中输入: PATH="$PATH:yourpath" :yourpath是要添加的环境变量(即要添加目录的绝对路径,例:/home/myprog ...
- 微端游戏启动器launcher的制作(序篇)
公司要做一个游戏接入腾讯QQ游戏大厅,腾讯要求制作一个launcher,公司之前并没有接入过腾讯,所以大家其实都不懂,而我又是新人,所以刚拿到这个任务的时候整个人就是一个大写的懵逼.在网上查找了不少的 ...