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 ...
随机推荐
- 1-1Controller之Request
laravel5.5版本 //路由: Route::any('request1',['uses'=>'StudentController@request1']); //控制器中的方法: publ ...
- Win10系列:VC++绘制几何图形4
三角形绘制完成以后,接下来介绍如何给项目添加主入口函数.打开D2DBasicAnimation.h头文件,添加如下的代码定义一个DirectXAppSource类. //定义类DirectXAppSo ...
- 分布式锁与实现(一)基于Redis实现
目前几乎很多大型网站及应用都是分布式部署的,分布式场景中的数据一致性问题一直是一个比较重要的话题.分布式的CAP理论告诉我们“任何一个分布式系统都无法同时满足一致性(Consistency).可用性( ...
- (C/C++学习笔记)附页: C/C++各数据类型的相关说明
- cnn 经典网络结构 解析
cnn发展史 这是imageNet比赛的历史成绩 可以看到准确率越来越高,网络越来越深. 加深网络比加宽网络有效的多,这已是公认的结论. cnn结构演化图 AlexNet 诞生于2012年,因为当时用 ...
- HTML5触摸事件(touchstart、touchmove和touchend)
HTML5中新添加了很多事件,但是由于他们的兼容问题不是很理想,应用实战性不是太强,所以在这里基本省略,咱们只分享应用广泛兼容不错的事件,日后随着兼容情况提升以后再陆续添加分享.今天为大家介绍的事 ...
- oracle语句录
从表中选出一个某个单位最近的记录 select * from RSDL_SHXX where sbsj in (select max (sbsj) from RSDL_SHXX where DW_ID ...
- 20165214 实验二 Java面向对象程序设计
一.实验报告封面 课程:Java程序设计 班级:1652班 姓名:朱文远 学号:20165214 指导教师:娄嘉鹏 实验日期:2018年4月16日 实验时间:13:45 - 15:25 实验序号:二 ...
- synchronized(五)
package com.bjsxt.base.sync005;/** * synchronized的重入 * @author alienware * */public class SyncDubbo2 ...
- 五、LCD屏填充纯色
废话不说,直接上代码: lcd.c #include "lcd.h" static int PEN_COLOR = LCD_RED; /* 定义画笔(前景)颜色 */ static ...