ZOJ 1007:Numerical Summation of a Series(数学)
Numerical Summation of a Series
Time Limit: 10 Seconds Memory Limit: 32768 KB Special Judge
Produce a table of the values of the series
for the 2001 values of x, x= 0.000, 0.001, 0.002, ..., 2.000. All entries of the table must have an absolute error less than 0.5e-12 (12 digits of precision). This problem is based on a problem from Hamming (1962), when mainframes were very slow by today's microcomputer standards.
Input
This problem has no input.
Output
The output is to be formatted as two columns with the values of x and y(x) printed as in the C printf or the Pascal writeln.
printf("%5.3f %16.12f\n", x, psix ) writeln(x:5:3, psix:16:12)
As an example, here are 4 acceptable lines out of 2001.
0.000 1.644934066848
...
0.500 1.227411277760
...
1.000 1.000000000000
...
2.000 0.750000000000
The values of x should start at 0.000 and increase by 0.001 until the line with x=2.000 is output.
Hint
The problem with summing the sequence in equation 1 is that too many terms may be required to complete the summation in the given time. Additionally, if enough terms were to be summed, roundoff would render any typical double precision computation useless for the desired precision.
To improve the convergence of the summation process note that
which implies y(1)=1.0. One can then produce a series for y(x) - y(1) which converges faster than the original series. This series not only converges much faster, it also reduces roundoff loss.
This process of finding a faster converging series may be repeated to produce sequences which converge more and more rapidly than the previous ones.
The following inequality is helpful in determining how may items are required in summing the series above.
题意
给出式子 ,输出x=0.001~x=2.000时的结果。要求保留到小数点后12位
思路
数学题,可以首先根据题目得到,利用这个条件对题目中的式子进行化简:
化简结束后,可以看出对求值是本题的关键
因为当k大到一定值的时候,,(百度看了大佬们的题解后,当k>=20000时可以看做k,这个k的值应该不是唯一的,在不超时的情况下足够大就行)。所以可以对20000项之后进行累加,累加到一个很大的数就行了(比如100W)即计算的值。然后对于1~20000之内的和用循环求出即可
AC代码
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const double eps=1e-12;
const double maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int main(int argc, char const *argv[])
{
double res=0.0;
double _;
for(double i=20000.0;i<=maxn;i+=1.0)
res+=1.0/(i*i*(i+1));
for(double k=0.000;k<=2.0005;k+=0.001)
{
_=res;
for(double i=20000;i>=1;i--)
{
_=_+1.0/(i*(i+k)*(i+1));
}
_=_*(1-k);
_+=1;
printf("%5.3f %16.12f\n",k,_);
}
return 0;
}
ZOJ 1007:Numerical Summation of a Series(数学)的更多相关文章
- ZOJ 1007 Numerical Summation of a Series
原题链接 题目大意:x的取值从0.000到2.000,输出每个x对应的y(x)的值 解法:参考了这篇日志http://www.cnblogs.com/godhand/archive/2010/04/2 ...
- 1007 Numerical Summation of a Series
简单入门题.按照题目给的指导编程,算多少数要理解题意. #include <stdio.h> int main(){ int k,ssx; double x,psix; ;ssx<= ...
- ZOJ007 Numerical Summation of a Series(纯数学)
#include<bits/stdc++.h> using namespace std; int main() { double i; double k; for(i=0.000;i-2. ...
- zoj 2095 Divisor Summation
和 hdu 1215 一个意思// 只是我 1坑了 1 时应该为0 #include <iostream> #include <math.h> #include <map ...
- HDU 4791 & ZOJ 3726 Alice's Print Service (数学 打表)
题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showP ...
- zoj 2818 Root of the Problem(数学思维题)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818 题目描述: Given positive integer ...
- ZOJ 3829 Known Notation(字符串处理 数学 牡丹江现场赛)
题目链接:problemId=5383">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5383 Do you ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
随机推荐
- 维护一个旧程序 linq2sql,出现row not found or changed的异常
维护一个旧程序 linq2sql,出现row not found or changed的异常, 查博客园,文章都是一大抄,都不对. 想想之前都能保存的.这个异常是在加了字段之后出现的. 因为用vs.n ...
- Use of undefined constant FTP_BINARY - assumed 'FTP_BINARY
用Laravel中的filesystems里面的ftp上传文件时报错.在windows上开发,文件上传的时候碰到上面的问题,搜了些资料,发现是php7的ftp拓展默认未开启. 第一步:检查extens ...
- C++解析四-友员函数、内联函数、静态成员
友元函数 类的友元函数是定义在类外部,但有权访问类的所有私有(private)成员和保护(protected)成员.尽管友元函数的原型有在类的定义中出现过,但是友元函数并不是成员函数.友元可以是一个函 ...
- learning ddr mode reigster set command cycle time tMRD and tMOD
tMRD: tMOD:
- 使用laravel搭建CURD后台页面
配置即一切 一切皆于需求,后台从0开始搭建,但是写了一两个页面后发现太多的是对单表的增删改查操作,于是就想到了,能不能做一个快速搭建的后台.想到一句话,配置即一切.如果一个CURD后台能只进行配置就自 ...
- day29 socketsever ftp功能简单讲解
今日所学 一.ftp上传简单实例 二.socketsever的固定用法 三.验证合法性连接 1.ftp上传实例 这个题目是我们现在网络编程比较基础一点的题目 下面我们只写简单上传的代码 上传服务端的代 ...
- docker(三)容器的基本操作
下载镜像 docker pull name 基本启动容器 docker run IMAGE command args run 在新容器中运行 IMAGE 镜像名称 command 容器命令 args ...
- 图的拓扑排序,AOV,完整实现,C++描述
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- 对FPGA的时钟资源理解(更新中)
7系列FPGA中包含了多达24个CMT(时钟管理单元)(实际上V7常见只有20个),MMCM和PLL均为时钟综合器,对外部输入时钟.内部时钟进行处理,生成需要的低抖动时钟.PLL是MMCM的功能子集, ...
- Web开发框架DevExtreme发布v18.2.5|附下载
DevExtreme Complete Subscription是性能最优的 HTML5,CSS 和 JavaScript 移动.Web开发框架,可以直接在Visual Studio集成开发环境,构建 ...