Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请教一下这个代码哪里错了,和标程对拍十几组数据全对#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator