#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的更多相关文章

  1. POJ题目细究

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

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

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

  3. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  4. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  5. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  6. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  7. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  8. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  9. POJ 2255. Tree Recovery

    Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 De ...

随机推荐

  1. 内核同步机制 RCU

    Evernote分享地址:http://www.evernote.com/shard/s133/sh/8807320d-f54d-4e90-a31b-e2a3d35509ee/7539dc3931b8 ...

  2. try-catch-finally中return语句的执行

    catch里return后还会执行finally吗??在java里,是的.但是值得注意的是,在存在try-catch-finally的方法中,return可能出现的位置有4个,在try中,在catch ...

  3. Mybatis 的日志管理

    Mybatis通过日志工厂提供日志信息,Mybatis内置的日志模版是log4j,commons.log,jdk log也可以通过slf4j简单日志模版结合log4j使用日志信息输出.具体选择哪个日志 ...

  4. iOS 中使用md5加密

    #import <CommonCrypto/CommonDigest.h> @implementation MD5Util +(NSString *)encode:(NSString *) ...

  5. [转]UDP/TCP穿越NAT的P2P通信方法研究(UDP/TCP打洞 Hole Punching)

     [转]UDP/TCP穿越NAT的P2P通信方法研究(UDP/TCP打洞 Hole Punching) http://www.360doc.com/content/12/0428/17/6187784 ...

  6. 从JetBrains公司产品给我的商业模式启示

    JetBrains是捷克一家公司,专门从事IDE工具的开发,运营的产品有十几个.我因为使用JavaScript IDE工具而了解了WebStorm.进而了解了开发WebStorm的公司JetBrian ...

  7. Js作用域与作用域链详解[转]

     一直对Js的作用域有点迷糊,今天偶然读到JavaScript权威指南,立马被吸引住了,写的真不错.我看的是第六版本,相当的厚,大概1000多页,Js博大精深,要熟悉精通需要大毅力大功夫. 一:函数作 ...

  8. WEB相关文件的加载顺序

    一. 1.启动一个WEB项目,WEB容器会先去读取它的配置文件web.xml,读取<context-param>和<listener>两个节点. 2.接着,容器创建一个Serv ...

  9. 理解bashrc和profile[转载]

    这儿有一篇文章不错 https://wido.me/sunteya/understand-bashrc-and-profile/ http://blog.csdn.net/luotuo44/artic ...

  10. CSS3图片旋转特效

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...