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

WA了好几次,竟然是因为e和pi的精确度不够

Posted by lizimeng at 2016-02-13 15:31:31 on Problem 1423
#include <stdio.h>
#include <math.h>
#define e 2.7182818284590452354
#define pi 3.141592653589793239

int main()
{
    int n,m,i,b;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&m);
        if(m==1)
            b = 1;
        else
            b = m*log10(m/e) + log10(2*pi*m)/2 + 1;
        printf("%d\n",b);
    }
    return 0;
}

之前,e和pi的位数都取小数点后五位,发现对于很多数结果是错的。

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