poj-3112 Pie
来源:互联网 发布:北师珠网络教学 编辑:程序博客网 时间:2024/06/05 10:56
题意:某人过生日,他的朋友来他家参加party并且每人都拿来一块pie,现在需要把pie都分开让每个人都能享用,并且一定保证完整性,为了能公平的分给每个人,就算浪费也可以。问最多每个人可以得到多少体积的pie
思路:由于需要求圆柱体积所以π是一个问题,我们先把所有体积里的π提出来,然后二分枚举R^2(也就是体积),最后再乘上π即可。(注意π的精度需要很高)
#include <iostream>#include <algorithm>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>#include <queue>#define INF 0x3f3f3f3f#define mod 100000000using namespace std;double esp=1e-5;int main(){ int t; int n,f; double r[20000]; scanf("%d",&t); while(t--) { double sum =0 ; scanf("%d%d",&n,&f); f++; for(int i=0;i<n;i++) { scanf("%lf",&r[i]); r[i]=r[i]*r[i]; sum += r[i]; } double low=0,high=sum/f,mid; int cnt=0; while(high-low>esp) { cnt=0; mid=(low+high)/2; for(int i=0;i<n;i++) { cnt += (int)r[i]/mid; } if(cnt<f) high=mid; else low=mid; } printf("%.4f\n",mid*3.1415926535898); } return 0;}
0 0
- poj-3112 Pie
- POJ pie
- pie poj
- POJ-3122 Pie
- POJ 3122 Pie 二分
- POJ 3122 Pie 二分
- poj 3122 pie
- POJ 3122 Pie
- poj 3122 la3635 pie
- POJ 3122 Pie
- POJ-3122-Pie
- POJ 3122 Pie
- POJ 3122 Pie
- poj 3122 Pie
- poj 3122 pie
- POJ 3122 Pie
- POJ-3122 Pie
- POJ 3122--Pie
- C#套接字使用
- opencl: C++ 接口(cl.hpp)创建kernel
- Java基础知识(一)
- centos的nginx安装
- Contest Hunter - IHHH
- poj-3112 Pie
- 【漫画解读】HDFS存储原理
- 安卓布局:android:gravity 与 andorid:layout_gravity的区别
- python matplotlib绘图时图例显示问题
- 编写函数取得上一月的最后一天
- iOS 定位失败 非洲 经纬度为0,0
- Linux Redis 配置认证密码
- ReactiveCocoa框架到底是多强大
- 浅谈Echarts 使用配置