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

I Think I Need a Houseboat

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 9530    Accepted Submission(s): 2733

Problem Description

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.)

Input

The first line of input will be a positive integer indicating how many data sets will be included (N).

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.

Output

For each data set, a single line of output should appear. This line should take the form of:

“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.

Sample Input

2
1.0 1.0
25.0 0.0

Sample Output

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;
}
时间: 2024-08-02 16:43:52

HDU1065 I Think I Need a Houseboat 【数学递推】的相关文章

uva live 4123 Glenbow Museum 数学递推

// uva live 4123 Glenbow Museum 数学递推 // // 题目大意: // // 对于一个边平行于坐标轴的多边形,我们可以用一个序列来描述,R和O,R表示 // 该顶点的角度为90度,O表示该定点的角度为270.给定序列的长度.问能由这些RO序 // 列组成的星型多边形(内部存在一个点可以看到所有的节点的多边形)的方法数有多少. // // 解题思路: // // 顶点数一定是序列的长度.n小于4无法组成多边形.n为奇数的时候也不行.设R的个数有 // x个,O的个数

HDU2047 阿牛的EOF牛肉串 【数学递推】

阿牛的EOF牛肉串 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 19521    Accepted Submission(s): 9125 Problem Description 今年的ACM暑期集训队一共有18人,分为6支队伍.其中有一个叫做EOF的队伍,由04级的阿牛.XC以及05级的COY组成.在共同的集训生活中,大家建立了深

uva 766 - Sum of powers(数学+递推)

题目连接:uva 766 - Sum of powers 题目大意:将Sk(n)=∑i=1nik化简成Sk(n)=ak+1nk+1+aknk+?+a0M 解题思路: 已知幂k,并且有(n+1)k=C(kk)nk+C(k?1k)nk?1+?+C(0k)n0结论. 所以令 (n+1)k+1?nk+1=C(kk+1)nk+C(k?1k+1)nk?1+?+C(0k+1)n0 nk+1?(n?1)k+1=C(kk+1)(n?1)k+C(k?1k+1)(n?1)k?1+?+C(0k+1)(n?1)0 - 2

HRBUST1589(数学递推)

彩桥 Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %lld , %llu Java class name: Main [Submit] [Status] [Discuss] 题目链接:http://acm.hrbust.edu.cn/vj/index.php?c=problem-problem&id=75523 Description Cc用了药水之后状态全满,现在出现在他们眼前的是一个悬崖,悬崖之间有

ACM学习历程——ZOJ 3822 Domination (2014牡丹江区域赛 D题)(概率,数学递推)

Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows and M columns. Every day after work, Edward will place

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 ≤ i },可以理解为前j-1个数之和为i-k,最后一个数为k 还有一种更快的递推办法,把这个问题转化为将N个小球放到K个盒子中的方法数,盒子可以为空. 就等价于求x1 + x2 +...+ xK = N的非负整数解的个数,根据组合数学的知识容易算出结果为C(N+K-1, K-1). 所以也可以这样递推

ACM学习历程——HDU4814 Golden Radio Base(数学递推) (12年成都区域赛)

Description Golden ratio base (GRB) is a non-integer positional numeral system that uses the golden ratio (the irrational number (1+√5)/2 ≍ 1.61803399 symbolized by the Greek letter φ) as its base. It is sometimes referred to as base-φ, golden mean b

ACM学习历程——HDU4472 Count(数学递推) (12年成都区域赛)

Description Prof. Tigris is the head of an archaeological team who is currently in charge of an excavation in a site of ancient relics.        This site contains relics of a village where civilization once flourished. One night, examining a writing r

ACM学习历程—Hihocoder 1164 随机斐波那契(数学递推)

时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 大家对斐波那契数列想必都很熟悉: a0 = 1, a1 = 1, ai = ai-1 + ai-2,(i > 1). 现在考虑如下生成的斐波那契数列: a0 = 1, ai = aj + ak, i > 0, j, k从[0, i-1]的整数中随机选出(j和k独立). 现在给定n,要求求出E(an),即各种可能的a数列中an的期望值. 输入 一行一个整数n,表示第n项.(1<=n<=500) 输出 一行一个