zoukankan      html  css  js  c++  java
  • ZOJ 1049 I Think I Need a Houseboat

    原题链接

    题目大意:Fred想在Louisiana买一套房子,但是堤坝不牢固,每年都要被河水侵蚀50平方英里。题目给出他豪宅的坐标,要求他被迫移民搬迁的年份。

    解法:也没什么好说的,先求出两点间的距离,即半径,然后算出面积,在除以每年塌方的面积,向上取整即可。

    参考代码:

    #include <stdio.h>
    #include <math.h>
    #define PI 3.14
    int main(){
    	int n=1,N,year;
    	float X,Y,dist,area;
    	scanf("%d",&N);
    	while(n<=N){
    		scanf("%f%f",&X,&Y);
    		dist = X*X+Y*Y;
    		dist = sqrt(dist);
    		area = PI*dist*dist/2/50;
    		year = ceil(area);
    		printf("Property %d: This property will begin eroding in year %d.
    ",n,year);
    		n++;
    	}
    	printf("END OF OUTPUT.");
    	return 0;
    }
  • 相关阅读:
    volatile关键字
    const关键字祥解
    extern关键字祥解
    gcc和g++使用澄清
    [APIO2014]连珠线
    点名
    四轮车
    盘子序列
    序列问题
    长途旅行
  • 原文地址:https://www.cnblogs.com/naive/p/3568748.html
Copyright © 2011-2022 走看看