#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. 博客导出工具(C++实现,支持sina,csdn,自定义列表)

    操作系统:windowAll 编程工具:visual studio 2013 编程语言:VC++ 最近博文更新的较频繁,为了防止账号异常引起csdn博文丢失,所以花了点时间做了个小工具来导出博文,用做 ...

  2. OpenStack:安装Horizon

    1. 安装:# apt-get install memcached libapache2-mod-wsgi openstack-dashboard!Note for Ubuntu users# apt ...

  3. OC开发中运用到的枚举

      一  常见枚举的定义: typedef enum { LOGIN_SUCCESS, USER_NAME, USER_PASSWORD, OLD_LAT, OLD_LNG }FIELD_SAVED; ...

  4. java数据结构和算法------合并排序

      package iYou.neugle.sort; public class Merge_sort { public static void MergeSort(double[] array, i ...

  5. 数据库的编码浅谈(ZHS16GBK与US7ASCII)

     数据库的编码浅谈(ZHS16GBK与US7ASCII) 2007-11-15 17:14:18 分类: Oracle SQL> SELECT RAWTOHEX('郭A军') from dual ...

  6. action属性

    action属性 2013年7月8日 14:52 Path: action的访问路径,以"/"开头 Type: action的类型 Name: action使用的actionFor ...

  7. EF之外键Include() left join

    项目中用EF实现外键查询出的数据, 查询数量正确, 但实现返回数据集数量不对 //DbContext.cs HasRequired(s => s.ClassRoom) .WithMany() . ...

  8. ThinkDev.Logging-Queue模块介绍

    Queue,ThinkDev.Logging对内存级队列的封装. 主要针对需要简单进程内内存级队列提供支持,应用无需关心存储及线程. 配置例子: <!-- 队列对象 --> <Que ...

  9. 华为HG8240光猫-破解-联通-2016-telnet-http

    序 我与大家想法基本一致,拿到联通的光猫后,心想它应该是个路由器吧,如果让它自己拨号上网就好了,即省一台路由器,又省电了.抱着这个想法,在2013年里,我搜罗了不少文章,经过Q群,搜索,询问,阅读,理 ...

  10. 4554: [Tjoi2016&Heoi2016]游戏 二分图匹配

    题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=4554 题解: 如果没有硬石头的话,就是’*‘点对应的行列建边,然后跑最大匹配 硬石头什么 ...