| ||||||||||
| 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 | |||||||||
为什么printf("%lf")WA,printf("%f")AC?#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include <iomanip>
#include<algorithm>
#define RG register int
#define rep(i,a,b) for(RG i=a;i<=b;++i)
#define per(i,a,b) for(RG i=a;i>=b;--i)
#define ll long long
#define inf (1<<29)
#define maxn 1005
#define eps 1e-8
using namespace std;
int n;
double a,ans=1e20;
double H[maxn];
inline int read()
{
int x=0,f=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
return x*f;
}
int check(double b)
{
double A=a,B=b,C;
rep(i,3,n)
{
C=2.0*B+2.0-A;
if(C<0) return 0;
A=B,B=C;
}
ans=min(ans,C);
return 1;
}
int main()
{
n=read();scanf("%lf",&a);
double l=-1,r=1030,mid;
while(r-l>eps)
{
mid=(l+r)/2;
if(check(mid)) r=mid;
else l=mid;
}
printf("%.2f",ans);//printf("%.2lf",ans);waaaaa?
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator