Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:why

Posted by swordspirit at 2009-07-28 18:04:38 on Problem 1538
In Reply To:why Posted by:lookus at 2004-09-26 00:27:42
> #include <stdio.h>
> void main()
> {
> 	int y[11],n,i,j,x;
> 	double m,l;
> 	while(scanf("%d",&n),n!=0)
> 	{
> 		for(i=1;i<=n;i++)
> 			scanf("%d",&y[i]);
> 		scanf("%d",&x);
> 		for(i=2;i<=n;i++)
> 			if(y[i]!=y[1])
> 				break;
> 		if(i>n)
> 		{
> 			printf("Term %d of the sequence is %d\n",x+n,y[1]);
> 			continue;
> 		}//////我用的拉格朗日插值公式,但为什么要加上这个if后才AC呢
> 		x+=n;
> 		m = 0;
> 		for(i=1;i<=n;i++)
> 		{
> 			l=1;
> 			for(j=1;j<=n;j++)
> 			{
> 				if(i==j)
> 					continue;
> 				l*=(x-j);
> 				l/=(i-j);
> 			}
> 			l *= y[i];
> 			m+=l;
> 		}
> 		printf("Term %d of the sequence is %.0lf\n",x,m);
> 	}
> }
因为那个是常数列

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator