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

大概只有我一个人用拉格朗日插值做的……

Posted by YanXB at 2015-05-11 16:27:14 on Problem 2583
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int f(int x1,int y1,int x2,int y2,int x3,int y3,int x);
int main(void)
{
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		printf("%d %d %d",f(0,a,1,b,2,c,3),f(0,a,1,b,2,c,4),f(0,a,1,b,2,c,5));
	}
	return (0);
}
int f(int x1,int y1,int x2,int y2,int x3,int y3,int x)
{
	return ((x-x2)*(x-x3)*y1/(x1-x2)/(x1-x3)+(x-x1)*(x-x3)*y2/(x2-x1)/(x2-x3)+(x-x1)*(x-x2)*y3/(x3-x1)/(x3-x2));
}

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