#include <bits/stdc++.h>
using namespace std;
const int N=200010;
const double pi=acos(-1.0);
double h,t,ans;
int check(double r)
{
if(pow(r,pi)>=h*(pi*r*r-r)) return 1;
else return 0;
}
double rr(double l,double r1)
{ double mid;
while(r1>l)
{ mid=(l+(r1-l)/2);
if(r1-l<1e-8) break;
if(check(mid)) r1=mid;
else l=mid;
}
return mid;
}
int main()
{
ios::sync_with_stdio(false);
while(cin>>t)
{
while(t--)
{cin>>h;
ans=rr(0,100000);
printf("%.4lf\n",ans);
}
}
}
#include <bits/stdc++.h>
using namespace std;
int a[100010],N,M,ma,price,ans,total;
int check (int price)
{
int t=0,sum=0;
for(int i=0; i<N; i++)
{
sum+=a[i];
if(sum>price)
{
t++;
sum=a[i];
}
}
if(t>M) return 1;
else
return 0;
}
int seek(int l,int r)
{
int m;
while(r>=l)
{
m=l+(r-l)/2;
if(check(m)) l=m+1;
else { ans=m;r=m-1;}
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
while(cin>>N>>M)
{ total=0;
ma=0;
for(int i=0; i<N; i++)
{
cin>>a[i];
if(a[i]>ma) ma=a[i];
total+=a[i];
}
printf("%d\n",seek(ma,total));
}
return 0;
}
买古董
#include <bits/stdc++.h>
using namespace std;
int a[100010],N,M,ma,T,price,ans,total;
int check (int price)
{
int t=0,sum=0;
for(int i=0; i<N; i++)
{
sum+=a[i];
if(sum>price)
{
t++;
sum=a[i];
}
}
if(t>=M) return 1;//
else
return 0;
}
int seek(int l,int r)
{
int m;
while(r>=l)
{
m=l+(r-l)/2;
if(check(m)) l=m+1;
else { ans=m;r=m-1;}
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin>>T;
for(int i=0;i<T;i++)
{
cin>>N>>M;
total=0;
ma=0;
for(int i=0; i<N; i++)
{
cin>>a[i];
if(a[i]>ma) ma=a[i];
total+=a[i];
}
printf("%d\n",seek(ma,total));
}
return 0;
}