BZOJ 1011 [HNOI2008]遥远的行星 (误差分析)
1011: [HNOI2008]遥远的行星
Time Limit: 10 Sec Memory Limit: 162 MBSec Special Judge
Submit: 4974 Solved: 1864
[Submit][Status][Discuss]
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%,也算对
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#include <list>
#include <assert.h>
#include <bitset>
#include <numeric>
#define debug() puts("++++")
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x)*(x))
#define ms(a,b) memset(a, b, sizeof a)
#define sz size()
#define pu push_up
#define pd push_down
#define cl clear()
#define all 1,n,1
#define FOR(i,x,n) for(int i = (x); i < (n); ++i)
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const LL LNF = 1e17;
const double inf = 1e20;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int maxn = 1e5 + 10;
const int maxm = 3e5 + 10;
const int mod = 100003;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, -1, 0, 1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c) {
return r >= 0 && r < n && c >= 0 && c < m;
} double sum[maxn];
double b[maxn]; int main(){
double a;
scanf("%d %lf", &n, &a);
for(int i = 1; i <= n; ++i){
scanf("%lf", b + i);
sum[i] = sum[i-1] + b[i];
double ans = 0.;
int t = i * a + eps;
if(i > 100){
double xx = i - i * a / 2.;
ans = sum[t] * 1. * b[i] / xx;
}
else {
for(int j = 1; j <= t; ++j)
ans += b[i] * 1. * b[j] / (i - j);
}
printf("%.6f\n", ans);
}
return 0;
}
BZOJ 1011 [HNOI2008]遥远的行星 (误差分析)的更多相关文章
- BZOJ 1011 [HNOI2008]遥远的行星
1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 2559 Solved ...
- [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 ...
- 1011: [HNOI2008]遥远的行星
1011: [HNOI2008]遥远的行星 Time Limit: 10 Sec Memory Limit: 162 MBSec Special JudgeSubmit: 2241 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 ...
- 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为很小的常量,故直观上说每颗行 ...
随机推荐
- 前端-CSS-6-盒子模型
上面的布局宽度div{ width: 200px; height: 200px; border: 10px solid red; padding: 20px; } ------------------ ...
- Windows窗体技术
Windows窗体技术 Winform例子下载 https://pan.baidu.com/s/1zXO8gVuFAeKQ_Tnz55A4VQ 密码:i1r6
- inline和inline-block的间隙问题
我们在前端布局的时候,会偶尔发现,在具有inline/inline-block属性的元素间存在一小段间隙,网上有些文章说这个间隙是6px,但我觉得应该是一个空格的宽度. 这里以inline-block ...
- sql一个题的解法分析讲解
本篇讲述的是对一个sql面试题的细致语法讲解.关于执行流程(on where),内连接,外连接(左右)上实用.关于这些基本的语法知识请参考我前面的sql基本语法. S(SNO,SNAME)学生学号,姓 ...
- tensor flow 视频
http://v.youku.com/v_show/id_XMTYxMjQ2NTYyNA==.html?spm=a2h1n.8251843.playList.5!19~5~A.siMjNW&f ...
- SpringCloud组件和概念介绍1
一:什么是微服务(Microservice) 微服务英文名称Microservice,Microservice架构模式就是将整个Web应用组织为一系列小的Web服务.这些小的Web服务可以独立地编译及 ...
- tomcat发布webservice
编写后台代码: package test; import javax.jws.WebParam; import javax.jws.WebService; @WebService public cla ...
- 第五章 二叉树(c)二叉树
- collections之deque【双向队列】与Queue【单向队列】
今天来向大家介绍两个队列,一个是deque,双向队列,另外一个是Queue,单向队列,队列和堆栈不同,队列为先进先出,大家还需要注意一下,双向队列为collections模块中的类,而Queue为qu ...
- Volley下载图片存放在data/data下 networkImageView lrucache
networkImageView 设置图片的方法 (有效) imageView.setImageUrl("https://www.baidu.com/img/bd_logo1.png&qu ...