Numerical Summation of a Series


Time Limit: 10 Seconds      Memory Limit: 32768 KB      Special Judge


Produce a table of the values of the series


Equation 1

for the 2001 values of xx= 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


Equation 2

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.


Equation 3

题意

给出式子 ,输出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(数学)的更多相关文章

  1. ZOJ 1007 Numerical Summation of a Series

    原题链接 题目大意:x的取值从0.000到2.000,输出每个x对应的y(x)的值 解法:参考了这篇日志http://www.cnblogs.com/godhand/archive/2010/04/2 ...

  2. 1007 Numerical Summation of a Series

    简单入门题.按照题目给的指导编程,算多少数要理解题意. #include <stdio.h> int main(){ int k,ssx; double x,psix; ;ssx<= ...

  3. 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. ...

  4. zoj 2095 Divisor Summation

    和 hdu 1215 一个意思// 只是我 1坑了 1 时应该为0 #include <iostream> #include <math.h> #include <map ...

  5. HDU 4791 &amp; ZOJ 3726 Alice&#39;s Print Service (数学 打表)

    题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showP ...

  6. zoj 2818 Root of the Problem(数学思维题)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2818 题目描述: Given positive integer ...

  7. ZOJ 3829 Known Notation(字符串处理 数学 牡丹江现场赛)

    题目链接:problemId=5383">http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5383 Do you ...

  8. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  9. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

随机推荐

  1. python3练习-装饰器

    在廖雪峰的官方网站学习装饰器章节时,初步理解类似与面向切面编程.记录一下自己的课后习题解法. 问题: 请编写一个decorator,能在函数调用的前后打印出'begin call'和'end call ...

  2. chrome shortkeys

    [{"action":"scrolldownmore","activeInInputs":true,"blacklist" ...

  3. 神奇的口袋(dp)

    有一个神奇的口袋,总的容积是40,用这个口袋可以变出一 些物品,这些物品的总体积必须是40. John现在有n(1≤n ≤ 20)个想要得到的物品,每个物品 的体积分别是a1,a2……an.John可 ...

  4. linux网络操作 配置文件

    网络接口配置文件(网卡信息文件) '/etc/sysconfig/network-srcipts/ifcfg-*(eth0)' (注意区分大小写) DEVICE=eth0 网卡编号 HWADDR=08 ...

  5. node编译C++,比如安装node-gyp失败的问题

    遇到的这个问题是很多需要编译才能运行的node模块共有的问题. npm i -g windows-build-tools 首先以管理员身份打开命令行,然后在命令行下执行这一行命令. 然后重新运行你刚才 ...

  6. Java中数据类型相互转化

    1 将String 转换成int? A. 有两个方法: 1). int i = Integer.parseInt([String]); 或 i = Integer.parseInt([String], ...

  7. JAVA支付宝和微信(APP支付,提现,退款)

    公共参数图表:       接口 需要参数 通知方式 支付宝APP支付 应用公钥,应用私钥 异步 支付宝APP提现 应用公钥,应用私钥,支付宝公钥 同步 支付宝APP退款 应用公钥,应用私钥,支付宝公 ...

  8. Resharper插件如何启用原VS的智能提示

    第一步:vs2015选择工具—>选项—>文本编辑器—>C#—>常规—>语句结束,勾选自动列出成员,如下图: 第二步: 关闭Resharper智能提示,并设置为Visual ...

  9. 洛谷 P4515 [COCI2009-2010#6] XOR

    题意 平面直角坐标系中有一些等腰直角三角形,且直角边平行于坐标轴,直角顶点在右下方,求奇数次被覆盖的面积.N<=10.输入为x,y,r,分别表示三角形顶点的坐标与三角形的边长. 如: 总面积为0 ...

  10. 初识数据库、初识MySQL

    一.为什么要用数据库 # 1.将文件和程序存在一台机器上是很不合理的. # 2.操作文件是一件很麻烦的事. 所以就出现了一个新的概念 —— 数据库 你可以理解为 数据库 是一个可以在一台机器上独立工作 ...