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. SQLite 剖析

    由于sqlite对多进程操作支持效果不太理想,在项目中,为了避免频繁读写 文件数据库带来的性能损耗,我们可以采用操作sqlite内存数据库,并将内存数据库定时同步到文件数据库中的方法. 实现思路如下: ...

  2. ASCII编码、Unicode编码、UTF-8

    一.区别 ASCII.Unicode 是“字符集” UTF-8 .UTF-16.UTF-32  是“编码规则” 其中: 字符集:为每一个「字符」分配一个唯一的 ID(学名为码位 / 码点 / Code ...

  3. linux系统管理 启停命令

    mac下Linux的登录命名 'ssh -l root 192.168.10.109' password: xxxx ​ 退出登录 >> logout shutdown命令 要使用这个命令 ...

  4. HTML5 ②

    html代码中的各种标签和特殊符号: 1.<p>段落标签 默认会在段落前后都有空行</p>: 2.<hr/> 水平线标签     <br/>换行标签   ...

  5. 使用STL的next_permutation函数

    文章作者:姜南(Slyar) 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作. 下午研究了一下全排列算法,然后发现C++的STL有一个函数可以方便地生成全排列,这 ...

  6. MYSQL的存储函数

    创建存储函数与创建存储过程大体相同,格式如下: create function sp_name([func_parameter[,...]]) returns type [characteristic ...

  7. ubuntu下修改MYSQL数据库密码

    在介绍修改密码之前,先介绍一个文件/etc/MySQL/debian.cnf.其主要内容如下图: 里面有一个debian-sys-maint用户,这个用户只有Debian或Ubuntu服务器才有,所以 ...

  8. Linux3.10.0块IO子系统流程(2)-- 构造、排序、合并请求

    Linux块设备可以分为三类.分别针对顺序访问物理设备.随机访问物理设备和逻辑设备(即“栈式设备”)   类型 make_request_fn request_fn 备注 SCSI 设备等 从bio构 ...

  9. CountDownLatch在多线程程序中的应用

    一.CountDownLatch介绍 CountDownLatch是JDK1.5之后引入的,存在于java.util.concurrent包下,能够使一个线程等待其他线程完成动作后再执行.构造方法: ...

  10. 201621123001《Java程序设计》第1周学习总结

    1. 本周学习总结 认识java的三个层次:java语法 面向对象设计能力 应用 . 学习eclipse创建java文件的方法. 学习markdown的基本语法,了解写博客的几种常用形式. 了解JVM ...