zoukankan      html  css  js  c++  java
  • I Think I Need a Houseboat 1005 PKU

    description:

    某个地方被Mississippi河腐蚀每年都会有50square miles,而且总共腐蚀是个半圆,求给定一个点什么时候会被腐蚀

    solution:

    求该点到(0,0)的长度r,求以r为半径半圆的面积area,除以50即可得到答案

    1. 一个难点是浮点型精度的处理,但是好像多想了,题目给出HINT:No property will appear exactly on the semicircle boundary: it will either be inside or outside.

    1 #include <stdio.h>
    2
    3  #define PI 3.1415926535
    4  #define EPS 1e-6
    5
    6  int main()
    7 {
    8 int cases=0,i=0;
    9 double year=0;
    10 double area=0,x=0,y=0;
    11
    12 scanf ("%d",&cases);
    13
    14 for (i=1; i<=cases; i++)
    15 {
    16 scanf ("%lf %lf",&x,&y);
    17 area = (x*x+y*y)*PI/2;
    18
    19 year = area / 50;
    20 printf ("Property %d: This property will begin eroding in year %d.\n",
    21 i,(int)(year-EPS)+1);
    22 }
    23
    24 printf("END OF OUTPUT.\n");
    25
    26 return 0;
    27 }
  • 相关阅读:
    Oracle 基础系列之1.3 用户管理
    Oracle 系统常用命令
    Gogs安装
    centos7 Minimal安装没有ifconfig
    centos 上安装nodejs v8.0.0
    Linux 学习笔记
    使用 weinre 远程调试移动端页面
    Linux tree命令
    innodb分区
    Innodb表空间
  • 原文地址:https://www.cnblogs.com/eavn/p/1752629.html
Copyright © 2011-2022 走看看