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 1
m
100000 <tex2html_verbatim_mark>of money this person has, the cost 1
g
100 <tex2html_verbatim_mark>of a unit amount of grass this person plants, and the cost 1
f
100 <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 ...
随机推荐
- HDU 5191 Building Blocks
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5191 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- (一)MySQL基础篇
1.mysql简介 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库. 主流的数据库有:sqlserver,mysql,Oracle.SQLite.Access.MS SQL Se ...
- 201621123037 《Java程序设计》第8周学习总结
作业08-集合 1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 答: 思维导图: 其他-笔记: 2. 书面作业 1. ArrayList代码分析 1.1 解释ArrayLi ...
- CodeForces Round #527 (Div3) A. Uniform String
http://codeforces.com/contest/1092/problem/A You are given two integers nn and kk. Your task is to c ...
- Cmder命令行工具在Windows系统中的配置
一.Cmder简介 Cmder:一款用于Windows系统中,可增强传统cmd命令行工具的控制台模拟器(类似于Linux系统中的终端控制窗口) 特点: 无需安装,解压即用 可使用较多Linux命令,如 ...
- BZOJ 1190 梦幻岛宝珠(分组01背包)
跑了7000ms... 这是个体积和价值都超大的背包.但是体积保证为a*2^b的(a<=10,b<=30)形式.且n<=100. 于是可以想到按b来分组.这样的话每组最多为a*n*2 ...
- AtCoder Regular Contest 083 D: Restoring Road Network
题意 有一张无向带权连通图(点数<=300),给出任意两点i,j之间的最短路长度dis[i][j].问是否存在一张这样的无向图.如果不存在输出-1.如果存在输出所有这样的无向图中边权和最小的一张 ...
- Django 2.0 学习(17):Django 用户认证(auth模块)
Django 用户认证(auth模块) 一.认证登陆 在进行用户登陆验证的时候,如果是自己写代码,就必须要先查询数据库,看用户输入的用户名是否存在于数据库中:如果用户存在于数据库中,然后再验证用户输入 ...
- KMPnext数组自看
emm...无数次再看kmp了 因为一直没做相关的题..看了就忘看了就忘..emm.. next[i]表示去掉第i个元素后,自已的前缀和后缀完全匹配的最大长度 例 字符串 a b a b a b z ...
- 【题解】CF#713 E-Sonya Partymaker
这题真的想了挺久的,然而到最后也还是没想到怎样处理环的情况……网上竟然也完全没有题解,无奈之下到 CF 的 AC 代码里面去找了一份膜拜了一下.感谢~ 由于觉得这题有一定的难度,自己看代码也看了比较久 ...