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 wcysai at 2015-12-01 17:29:07 on Problem 1759
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
double a;
int n;
bool C(double x)
{
    int m=floor((-x))/2;
    return a+(m+1)*x+(m+1)*m>=0;
}
int main()
{
    scanf("%d %lf",&n,&a);
    double left=-a,right=0;
    for(int i=0;i<100;i++)
    {
        double mid=(left+right)/2;
        if(C(mid)) right=mid;
        else left=mid;
    }
    printf("%.2lf\n",a+(n-1)*right+(n-2)*(n-1));
    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