Grass is Green
Root | |
3719 - Grass is GreenTime limit: 3.000 seconds |
This year exactly n <tex2html_verbatim_mark>people bought land in Squareville_including you. When someone buys land, then the first thing they do is to plant grass on the land; everyone wants to make sure that their grass is greener than the neighbour's. Depending on the type of grass, planting it has a certain cost. The next thing to do is to build a fence around the land; the cost of the fence depends of the type of the fence (green or white, with or without barbed wire, electric or not, etc.) Everyone has a very particular idea about the type of grass and the type of fence they want. In fact, everyone firstly decided upon the type of grass and fence, and then bought the largest piece of land they could afford (i.e., they could buy the land, the grass, andthe fence). In Squareville, you can buy only square-shaped land, but you can buy any size you want. We assume that everyone plants grass across the whole area of land and everyone builds a fence around the full perimeter, i.e., on all four sides.
Having a larger garden means that you are more respected in Squareville. Therefore, you would like to know how many of the n <tex2html_verbatim_mark>people will have larger land than you. Your task is to write a program thatcalculates this number.
Input
The input contains several blocks of test cases. Each case begins with a line containing an integer 1nle10000 <tex2html_verbatim_mark>, the number of people buying land and a real number 0 < c < 100 <tex2html_verbatim_mark>, the cost of a unit area of land. The next n <tex2html_verbatim_mark>lines describe the n <tex2html_verbatim_mark>people; the first of these lines describes you. Each line contains three real numbers: the amount 1m100000 <tex2html_verbatim_mark>of money this person has, the cost 1g100 <tex2html_verbatim_mark>of a unit amount of grass this person plants, and the cost 1f100 <tex2html_verbatim_mark>of a unit length of fence this person builds.
The input is terminated by a block with n = c = 0 <tex2html_verbatim_mark>.
Output
For each test case, you have to output a single integer: how many people have larger land than you. Thus, if you have the largest land, then output `0'; if you have the smallest land, then output n - 1 <tex2html_verbatim_mark>.
Sample Input
5 1
32.0 5.0 1.0
16.0 1.0 1.0
63.0 2.0 3.0
68.0 10.0 3.0
88.0 1.0 10.0
0 0
Sample Output
1 解一元二次方程即可
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std; const double eps = 10e-8;
const int MAXN = 10005;
double m, c, g, f;
int n;
double p[MAXN]; int main()
{
while(scanf("%d %lf", &n, &c) && n && c)
{
for(int i = 0; i < n; i++)
{
scanf("%lf %lf %lf", &m, &g, &f);
p[i] = 8.0 * (-f + sqrt(f * f + (g + c) * m / 4.0)) / (g + c);
}
int cnt = 0;
for(int i = 1; i < n; i++)
{
if(fabs(p[i] - p[0]) < eps) continue;
if(p[i] > p[0]) cnt++;
}
printf("%d\n", cnt);
}
return 0;
}
Grass is Green的更多相关文章
- PHP 5.5 新特性
文章转自:http://wulijun.github.io/2013/07/17/whats-new-in-php-5-5.html http://www.cnblogs.com/yjf512/p/3 ...
- 第 14 章 结构和其他数据形式(enum枚举)
/*----------------------------- enum.c -- 使用枚举类型的值 -----------------------------*/ #include <stdi ...
- 【资料总结】html开发小实例
目 录 第1章 1 HTML的基本标签 1 第2章 25 表格基础 25 第3章 53 表单和框架 53 第4章 77 CSS样式表 77 第5章 104 使用Dreamweaver制作网页 104 ...
- [Tkinter 教程] 布局管理 (Pack Place Grid)
原系列地址: Python Tkinter 简介: 本文讲述如何使用 tkinter 的布局管理 (被称作 layout managers 或 geometry managers). tkinter ...
- PHP 数组使用之道
本文首发于 PHP 数组使用之道,转载请注明出处. 这个教程我将通过一些实用的实例和最佳实践的方式列举出 PHP 中常用的数组函数.每个 PHP 工程师都应该掌握它们的使用方法,以及如何通过组合使用来 ...
- [Tkinter 教程12] 布局管理 (Pack Place Grid)
简介: 本文讲述如何使用 tkinter 的布局管理 (被称作 layout managers 或 geometry managers). tkinter 有三种布局管理方式: pack grid p ...
- hdu----(1849)Rabbit and Grass(简单的尼姆博弈)
Rabbit and Grass Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 分形之概率学下的green tree
今天做的是分形之随机概率,可以和以前做的那个抛色子的做法非常相似,抛色子是用随机点数控制图形,今天做的树叶图形只是用概率的做法去控制图形而已,做法是如出一辙的: //图形界面 package ...
- python 安装nltk,使用(英文分词处理,词干化等)(Green VPN)
安装pip命令之后: sudo pip install -U pyyaml nltk import nltk nltk.download() 等待ing 目前访问不了,故使用Green VPN htt ...
随机推荐
- c# 简单日志记录
FileStream fs = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "log.txt",Fi ...
- CS小分队第一阶段冲刺站立会议(5月12日)
昨日成果:2048整体界面效果经组员韩雪冬美化之后档次提升了好几个,我为其添加了保存并显示最高分数的功能. 遇到困难:当我想把access数据库由accdb改成mdb时,发生未知错误 ,导致数据库无法 ...
- 团队作业4——第一次项目冲刺(Alpha版本)第一次
一.会议内容 制定任务内容 制作leangoo表格 初步工作 二.各人工作 成员 计划任务 遇见难题 贡献比 塗家瑜(组长) 后端与数据库通讯 无 1 张新磊 表设计 无 1 姚燕彬 测试计划编写 无 ...
- phpdisk 盲注 &前台任意用户登录
代码审核 文件 plugins\phpdisk_client\passport.php 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 $str ...
- Docker 安装与常用命令介绍
docker的镜像文件作用就是:提供container运行的文件系统层级关系(基于AUFS实现),所依赖的库文件.已经配置文件等等. 安装docker yum install -y docker 启动 ...
- (十二)Jmeter之Bean Shell的使用(一)
一.什么是Bean Shell BeanShell是一种完全符合Java语法规范的脚本语言,并且又拥有自己的一些语法和方法; BeanShell是一种松散类型的脚本语言(这点和JS类似); BeanS ...
- php面试必知必会常见问题
1 说出常用的10个数组方法 我觉得数组比较最能体现PHP基础语法的一个数据结构了,下面给大家列一下常用的10个关于操作数组的函数 in_array(判断数组中是否有某个元素) implode(将数组 ...
- 从装饰者模式的理解说JAVA的IO包
1. 装饰者模式的详解 装饰者模式动态地将责任附加到对象上.若要扩展功能,装饰者提供了比继承更有弹性 的替代方案. 装饰者模式设计类之间的关系: 其 中Component是一个超类,ConcreteC ...
- Spring事务管理Transaction【转】
Spring提供了许多内置事务管理器实现(原文链接:https://www.cnblogs.com/qiqiweige/p/5000086.html): DataSourceTransactionMa ...
- HDU4466_Triangle
今天比赛做的一个题目,不过今天终于感受到了复旦题目有多坑了. 题目的意思是给你一段长为n个单位长度的直线,你可以选择任意连续单位长度的线段组成三角形,可以组成任意你可以组成任意多个三角形,且要求其中所 ...