hdu 1065(推公式)

I Think I Need a Houseboat

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12114    Accepted Submission(s): 3407

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.

pi*R[n]^2-pi*R[n-1]^2 =100 得到 R[n]^2 = 100*n/pi

直接得结果,破题有毒,pi只能取3.1415926

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long LL;
const double pi = 3.1415926;

int main()
{
    int t;
    scanf("%d",&t);
    for(int i=1; i<=t; i++)
    {
        double x,y;
        scanf("%lf%lf",&x,&y);
        double r = x*x+y*y;  ///半径的平方
        printf("Property %d: This property will begin eroding in year %d.\n",i,(int)((r)*pi/100+1));
    }
    printf("END OF OUTPUT.\n");
    return 0;
}
时间: 2024-10-25 00:17:06

hdu 1065(推公式)的相关文章

HDU 5047 推公式+别样输出

题意:给n个‘M'形,问最多能把平面分成多少区域 解法:推公式 : f(n) = 4n(4n+1)/2 - 9n + 1 = (8n+1)(n-1)+2 前面部分有可能超long long,所以要转化一下,令a = 8n+1, b = n-1,将两个数都化为a1*10^8+b1的形式,则 (a1*10^8+b1)(a2*10^8+b2) =(a1a2*10^8 + a1b2 + a2b1)*10^8 + b1b2 + 2,由于a1,a2最多2为10^4左右,中间的数就都不会超过long long

HDU 4686 (推公式+矩阵快速幂)

题目连接:传送门 题意: 给定ai,bi的推倒公式,求sigma(ai*bi) ( 0<= i < n) 分析: A0 = A0 Ai = Ai-1*Ax+Ay B0 = B0 Bi = Bi-1*Bx+By 设Fi表示Ai*Bi Fi = Ai * Bi ===>    Fi = (Ai-1*Ax + Ay)*(Bi-1*Bx + By) ===>    Fi = Ax*Bx*(Ai-1*Bi-1) + Ax*By*Ai-1 + Bx*Ay*Bi-1 ===>    Fi

hdu 2197 推公式

题意:由0和1组成的串中,不能表示为由几个相同的较小的串连接成的串,称为本原串,有多少个长为n(n<=100000000)的本原串?答案mod2008.例如,100100不是本原串,因为他是由两个100组成,而1101是本原串. f[n]=2^n -  求和(f[i])  -2  其中i是n的大于等于2的约数.  那个-2是由0和1组成的串 一开始写数组,直接超了,没想到这里居然可以用map,新技能 1 #include<cstdio> 2 #include<iostream>

HDU 4873 ZCC Loves Intersection(JAVA、大数、推公式)

在一个D维空间,只有整点,点的每个维度的值是0~n-1 .现每秒生成D条线段,第i条线段与第i维度的轴平行.问D条线段的相交期望. 生成线段[a1,a2]的方法(假设该线段为第i条,即与第i维度的轴平行)为,i!=j时,a1[j]=a2[j],且随机取区间[0,n-1]内的整数.然后a1[i],a2[i]在保证a1[i]<a2[i]的前提下同样随机. 由于D条线段各自跟自己维度的轴平行,我们可以转换成只求第i个维度与第j个维度的相交期望,然后乘以C(2,n)就好了 显然线段[a1,a2]和线段[

HDU 4870 Rating(概率、期望、推公式) &amp;&amp; ZOJ 3415 Zhou Yu

其实zoj 3415不是应该叫Yu Zhou吗...碰到ZOJ 3415之后用了第二个参考网址的方法去求通项,然后这次碰到4870不会搞.参考了chanme的,然后重新把周瑜跟排名都反复推导(不是推倒)四五次才上来写这份有抄袭嫌疑的题解... 这2题很类似,多校的rating相当于强化版,不过原理都一样.好像是可以用高斯消元做,但我不会.默默推公式了. 公式推导参考http://www.cnblogs.com/chanme/p/3861766.html#2993306 http://www.cn

HDU 1165 Eddy&#39;s research II (推公式)

Eddy's research II Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3122    Accepted Submission(s): 1137 Problem Description As is known, Ackermann function plays an important role in the sphere

hdu 6128 Inverse of sum(推公式)

题目链接:hdu 6128 Inverse of sum 题意: 给你n个数,问你有多少对i,j,满足i<j,并且1/(ai+aj)=1/ai+1/aj 在%p意义下. 题解: 不愧是高中生,推公式神题. 将式子通分化简后可得(ai2+aj2+ai*aj)%p=0. 然后两边同时将两边乘(ai-aj),化简可得(ai3-aj3)%p=0. 然后就可以用map记录一下个数,并且减掉ai==aj时不合法的情况就行了. 1 #include<bits/stdc++.h> 2 #define F

2017多校第7场 HDU 6128 Inverse of sum 推公式或者二次剩余

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6128 题意:给你n个数,问你有多少对i,j,满足i<j,并且1/(ai+aj)=1/ai+1/aj 在%p意义下. 解法:官方题解说是用二次剩余来解,但是我并不会这玩意了.在网上看到一位大佬没有二次剩余直接通过推公式做出了这题,真是神奇.http://www.cnblogs.com/bin-gege/p/7367337.html  将式子通分化简后可得(ai2+aj2+ai*aj)%p=0 .然后两

Balls and Boxes---hdu5810(推公式)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5810 有n个球m个盒子,随机把球放到盒子中,求每个盒子球个数的方差的期望值 E[V]; 推公式吧,或者打表找规律结果就是n*(m-1)/(m*m)