POJ 1538
#include <iostream>
#include <iomanip>
using namespace std; int _v[];
//拉格朗日插值算法
int main()
{
//freopen("acm.acm","r",stdin);
int n;
int i;
int j;
int x;
double sum;
double temp;
while(cin>>n,n)
{
for(i = ; i <= n; ++ i)
{
cin>>_v[i];
}
cin>>x;
sum = ;
x += n;
for(i = ; i <= n; ++ i)
{
if(_v[i] != _v[])
{
break;
}
}
if(i > n)
{
sum = _v[n];
}
else
{
for(i = ; i <= n; ++ i)
{
temp = ;
for(j = ; j <= n; ++ j)
{
if(i == j)
{
continue;
}
temp *= (x-j);
temp /= (i-j);
}
temp *= _v[i];
sum += temp;
}
}
cout<<"Term "<<x<<" of the sequence is ";
cout<<setiosflags(ios::fixed)<<setprecision()<<sum<<endl;
}
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com
POJ 1538的更多相关文章
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2255. Tree Recovery
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
随机推荐
- oracle DML错误日志(笔记)
DML错误日志是oracle10gR2引入的一个类似于SQL*Loader的错误日志功能.它的基本原理是把任何可能导致语句失败的记录转移,放到一张错误日志表中. 具体使用如下: 1.使用DBMS_ER ...
- perl实现awk的功能
perl -nla -F/\t/ -e"...", 其中-n: while(<>){...}-l: chomp-a: autosplit-F: 与a结合的分隔模式-e: ...
- Run ionic web app in nodejs
首先需要express插件:sudo npm install express 将ionic project的www拷贝至wwwroot,新建server.js: var express = requi ...
- pcre 使用
1.主页地址:http://www.pcre.org/ 下载pcre-7.8.tar.bz22.解压缩: tar xjpf pcre-7.8.tar.bz23.配置: cd p ...
- 史上最佳 Mac+PhpStorm+XAMPP+Xdebug 集成开发和断点调试环境的配置
在上一篇 PHP 系列的文章<PHP 集成开发环境比较>中,我根据自己的亲身体验,非常简略的介绍和对比了几款常用的集成开发环境,就我个人而言,比较推崇 Zend Studio 和 PhpS ...
- generate the next AttestationNumber, 格式是ICD-EPRG-DEV-0000000001,ICD-EPRG-DEV-0000000002
private static int GetNextAttestationNumber(string maxAttestationNumber) { //generate the next Attes ...
- HTML/CSS的学习过程一览
HTML/CSS的学习过程一览 说明 调试工具使用的是Google Chrome浏览器,其余浏览器出现的问题,这锅我不背[傲娇脸 可以使用浏览器查看源代码 网页列表 HTML_CSS_1 HTML基本 ...
- Notes of the scrum meeting(11/4)
meeting time:20:00~20:30p.m.,November 4th,2013 meeting place:20号公寓楼前 attendees: 顾育豪 ...
- 结对开发----找出“水王"
一.题目 三人行设计了一个灌水论坛.信息学院的学生都喜欢在上面交流灌水,传说在论坛上有一个“水王”,他不但喜欢发帖,还会回复其他ID发的每个帖子.坊间风闻该“水王”发帖数目超过了帖子数目的一半. 如果 ...
- xml基础学习笔记04
今天继续xml学习,主要是:SimpleXML快速解析文档.xml与数组相互转换 .博客中只是简单的做一个学习记录.积累.更加详细的使用方法,可以查看php手册 1.SimpleXML快速解析文档 前 ...