HDU1065 I Think I Need a Houseboat 【数学递推】
I Think I Need a Houseboat

Fred Mapper is considering purchasing some land in Louisiana to build his house on. In the process of investigating the land, he learned that the state of Louisiana is actually shrinking by 50 square miles each year, due to erosion caused by the Mississippi
River. Since Fred is hoping to live in this house the rest of his life, he needs to know if his land is going to be lost to erosion.
After doing more research, Fred has learned that the land that is being lost forms a semicircle. This semicircle is part of a circle centered at (0,0), with the line that bisects the circle being the X axis. Locations below the X axis are in the water. The
semicircle has an area of 0 at the beginning of year 1. (Semicircle illustrated in the Figure.)

Each of the next N lines will contain the X and Y Cartesian coordinates of the land Fred is considering. These will be floating point numbers measured in miles. The Y coordinate will be non-negative. (0,0) will not be given.
“Property N: This property will begin eroding in year Z.”
Where N is the data set (counting from 1), and Z is the first year (start from 1) this property will be within the semicircle AT THE END OF YEAR Z. Z must be an integer.
After the last data set, this should print out “END OF OUTPUT.”
Notes:
1. No property will appear exactly on the semicircle boundary: it will either be inside or outside.
2. This problem will be judged automatically. Your answer must match exactly, including the capitalization, punctuation, and white-space. This includes the periods at the ends of the lines.
3. All locations are given in miles.
2
1.0 1.0
25.0 0.0
Property 1: This property will begin eroding in year 1.
Property 2: This property will begin eroding in year 20.
END OF OUTPUT.
题意:给定一个从原点開始且中心在原点的半圆,每天以50mile^2的速度向外扩充。给你一个点。求第几天扩充的半圆能覆盖到它。
题解:这题最先開始想到的思路是模拟,可是考虑到模拟太耗时间又认为这题应该能找到规律,然后就拿着笔在演草纸上画了出来,规律是pi/2*(r[n]^2 - r[n-1]^2)=100; r[1]^2 = 100 / pi; r[n]表示第n天半圆覆盖的半径,这明显是一个等差数列,得到r[n]^2 = 100*n/pi;然后就该直接用公式了~
#include <stdio.h> int main()
{
int t;
double x, y;
scanf("%d", &t);
for(int i = 1; i <= t; ++i){
scanf("%lf%lf", &x, &y);
printf("Property %d: This property will begin eroding in year %d.\n",
i, int((x*x + y*y) * 3.1415926 / 100 + 1));
}
printf("END OF OUTPUT.\n");
return 0;
}
HDU1065 I Think I Need a Houseboat 【数学递推】的更多相关文章
- POJ 3597 种类数 数学+递推
http://poj.org/problem?id=3597 题目大意:把一个正多边形分成数个三角形或者四边形,问有多少种方案. 思路:http://www.cnblogs.com/Ritchie/p ...
- BZOJ-1045 糖果传递 数学+递推
1045: [HAOI2008] 糖果传递 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2975 Solved: 1327 [Submit][Sta ...
- UVa 10943 (数学 递推) How do you add?
将K个不超过N的非负整数加起来,使它们的和为N,一共有多少种方法. 设d(i, j)表示j个不超过i的非负整数之和为i的方法数. d(i, j) = sum{ d(k, j-1) | 0 ≤ k ≤ ...
- ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)
Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often ...
- ACM学习历程—Hihocoder 1164 随机斐波那契(数学递推)
时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 大家对斐波那契数列想必都很熟悉: a0 = 1, a1 = 1, ai = ai-1 + ai-2,(i > 1). ...
- ACM学习历程——HDU4814 Golden Radio Base(数学递推) (12年成都区域赛)
Description Golden ratio base (GRB) is a non-integer positional numeral system that uses the golden ...
- ACM学习历程——HDU4472 Count(数学递推) (12年长春区域赛)
Description Prof. Tigris is the head of an archaeological team who is currently in charge of an exca ...
- [luogu]P1066 2^k进制数[数学][递推][高精度]
[luogu]P1066 2^k进制数 题目描述 设r是个2^k 进制数,并满足以下条件: (1)r至少是个2位的2^k 进制数. (2)作为2^k 进制数,除最后一位外,r的每一位严格小于它右边相邻 ...
- LA 3882 经典约瑟夫环问题的数学递推解法
就是经典约瑟夫环问题的裸题 我一开始一直没理解这个递推是怎么来的,后来终于理解了 假设问题是从n个人编号分别为0...n-1,取第k个, 则第k个人编号为k-1的淘汰,剩下的编号为 0,1,2,3. ...
随机推荐
- 在ASP.NET开发中一些单词的标准缩写
有些词可能共用一些缩写.带星号的缩写或词来源于PeopleSoft标准. The following standard word abbreviations should be used in nam ...
- 三:动态SQL
:动态SQL 1.使用动态sql完成多条件查询 If:利用if实现简单的条件选择 Choose(when,otherwise):相当于java中的switch语句,通常与whenhe otherwis ...
- [转载] Java并发编程:Lock
转载自http://www.cnblogs.com/dolphin0520/p/3923167.html 以下是本文目录大纲: 一.synchronized的缺陷 二.java.util.concur ...
- pattern
A compiled representation of a regular expression. A regular expression, specified as a string, must ...
- 转贴---Linux服务器性能评估
http://fuliang.iteye.com/blog/1024360 http://unixhelp.ed.ac.uk/CGI/man-cgi?vmstat ------------------ ...
- hibernate:There is a cycle in the hierarchy! 造成死循环解决办法
下面是报的异常:在网上搜了关于:There is a cycle in the hierarchy!,才知道原来是因为死循环造成的!解决了好久,没有成功,后台不得已请教老大,老大说是因为在使用JSON ...
- 一道变态的Javascript面试题
转载http://cymoft.blog.51cto.com/324099/1260099 1 2 3 4 5 6 7 8 9 f = function() {return true;}; g = ...
- Chapter 8: Exceptional Control Flow
概述: 我们可以用一种“流”的概念来理解处理器的工作流程,PC(Program Counter)依次为a0,a1,a2,...,an-1,这个序列可以称作control flow.当然我们并不总是按顺 ...
- head first python菜鸟学习笔记(第三章)
1.os.chdir()切换到指定目录下,os.getcwd(),得到当前目录. >>> import os>>> os.chdir('D:\\CodeDocume ...
- kafka原理和实践(六)总结升华
系列目录 kafka原理和实践(一)原理:10分钟入门 kafka原理和实践(二)spring-kafka简单实践 kafka原理和实践(三)spring-kafka生产者源码 kafka原理和实践( ...