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 |
一直wa,后来发现居然考虑多了,代码如下#include<iostream> #include<cmath> #include<stdio.h> #include<string> using namespace std; int t; int n,f; int pie[10005]; const double pi = 3.14159265359; const double expp = 1e-6; int mmin,large; bool isok(double mid) { int count = 0; for(int i = 0;i < n;i++) { count += (int)(pie[i]*1.0/mid);//count += (int)(pie[i]*1.0/mid + 0.0000000001);这里我多考虑了,一直wa,改了就a了,我想不通,处理double//行数据不应该考虑吗? } if(count >= f) return true; return false; } void solve() { double low ,high,mid; low = 0; high = large*large*1.0; while(fabs(high - low) > expp) { mid = (low + high)/2; if(isok(mid)) { low = mid; } else high = mid; } printf("%.4f\n",mid*pi); return ; } void input() { cin>>n>>f; f++; large = -1; for(int i = 0;i < n;i++) { cin>>pie[i]; if(large < pie[i]) { large = pie[i]; } pie[i] = pie[i]*pie[i]; } return; } int main() { cin>>t; while(t--) { input(); solve(); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator