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

根本就不需高精度,double足以完成一切(c++)

Posted by ybc_c at 2010-09-05 22:53:21 on Problem 1517
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int Fun(int n)
{
	int s=1;
	if(n==0) return 1;
	for(int i=1;i<=n;i++)
		s*=i;
	return s;
}
int main()
{
	double e=0;
	int i;
	printf("n e\n");
	printf("- -----------\n");
	for(i=0;i<=9;i++)
	{
		double s;
		s=1/(double)Fun(i);
		e+=s;
		if(i==0 || i==1)
			printf("%d %.0lf\n",i,e);
		else if(i==2)
			printf("%d %.1lf\n",i,e);
		else
			printf("%d %.9lf\n",i,e);
	}
	return 0;
}

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