CodeChef submission 129738 (C++ 4.0.0-8) plaintext list. Status: AC, problem J7, contest NOV09. By kevindra (kevindra), 2009-11-10 22:27:53.
#include<iostream> //#include<conio.h> #include<math.h> #include<iomanip> using namespace std; double maxi; double p,s; int main(void){ //freopen("a.txt","r",stdin); int c,cases; cin>>cases; for(c=0;c<cases;c++){ double i,j; cin>>p>>s; double a,b; p/=4; s/=2; maxi=0; double low=0,high=p/2,mid; for(i=0;i<100;i++){ //cout<<mid<<endl; mid=(low+high)/2; a=mid; b=p-2*a; if(a*a+2*a*b<=s) low=mid; else high=mid; } maxi=a*a*b; low=0; for(i=0;i<100;i++){ mid=(low+high)/2; a=mid; b=(s-a*a)/(2*a); if(2*a+b<=p) low=mid; else high=mid; } if(maxi<a*b*c) maxi=a*b*c; } //getch(); return 0; }
Comments

