版本1和2间的区别
于2006-03-11 15:57:41修订的的版本1
大小: 875
编辑: czk
备注:
于2006-04-21 16:24:01修订的的版本2
大小: 1383
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 2: 行号 2:
http://acm.timus.ru/problem.aspx?space=1&num=1084
行号 22: 行号 23:
------
{{{#!cplusplus
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
行号 23: 行号 30:
http://acm.timus.ru/problem.aspx?space=1&num=1084
------
int main()
{
  int n, r;
  cin >> n >> r;
  if(n >= 2*r) {
    cout << fixed <<showpoint << setprecision(3) << 3.14159266*r*r << endl;
  } else if(n < r *1.41421356237){
    cout << fixed <<showpoint << setprecision(3) << 1.0*n*n << endl;
  } else {
    double theta = acos(n/2.0/r);
    cout << fixed << showpoint <<setprecision(3) << sin(theta)*r*n*2+r*r*(3.14159266-theta*4) << endl;
  }
}
}}}

A goat in a kitchen garden

http://acm.timus.ru/problem.aspx?space=1&num=1084

Time Limit: 2.0 second

Memory Limit: 1 000 K

Someone has let a goat in a square kitchen-garden and had bound it to a stake. The stake is driven into the ground in the very midst of the square. The goat is hungry as a hunter and very voracious, and eats everything that can be reached without leaving the square and tearing the roap. What area of the kitchen-garden will be ate round?

1. Input

contains lengths of the garden sides and a cord length in meters (natural numbers not exceeding 100, located in one line and separated with a space).

2. Output

should contain an area of the kitchen-garden (in square meters to within 3 symbols after a decimal point), ate round by the goat.

3. Sample Input

{{{10 6 }}}

4. Sample Output

{{{95.091 }}}


   1 #include <iostream>
   2 #include <iomanip>
   3 #include <cmath>
   4 using namespace std;
   5 
   6 int main()
   7 {
   8   int n, r;
   9   cin >> n >> r;
  10   if(n >= 2*r) {
  11     cout << fixed <<showpoint << setprecision(3) << 3.14159266*r*r << endl;
  12   } else if(n < r *1.41421356237){
  13     cout << fixed <<showpoint << setprecision(3) << 1.0*n*n << endl;
  14   } else {
  15     double theta = acos(n/2.0/r);
  16     cout << fixed << showpoint <<setprecision(3) << sin(theta)*r*n*2+r*r*(3.14159266-theta*4) << endl;
  17   }
  18 }

timus1084 (2008-02-23 15:36:53由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.