标签:pac ant const namespace include set while stdio.h 0.00
//题意:这是一个分蛋糕的游戏, t个测试数据,输入n, f n代表的是n块蛋糕,蛋糕的高为1, f代表的是f个人朋友,然后输入每份蛋糕的半径
// 将n块蛋糕分成 f+1 份 每一份都是完成的一块蛋糕,但是可以形状不一样,就每个人最大的蛋糕体积 v ,
//注意 pi 精度不能小于 3.14159265359 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <iostream> const double pi=3.14159265359; const double eps=0.000001; int a[10005]; using namespace std; int main(){ int t; cin>>t; while(t--){ int n, f; double sum = 0; cin>>n>>f; f = f+1; memset(a,0,sizeof(a)); for(int i=1;i<=n;i++){ cin>>a[i]; a[i] = a[i]*a[i]; sum += a[i]; } double left = 0, right = sum/f, mid; while(right-left>eps){ mid = (right+left)/2; int ant = 0; for(int i=1;i<=n;i++){ ant += (int)(a[i]/mid); } if(ant>=f)left = mid; else right = mid; } printf("%.4f",mid*pi); if(t!=0)printf("\n"); } }
标签:pac ant const namespace include set while stdio.h 0.00
原文地址:https://www.cnblogs.com/0526yao/p/10474316.html