ZOJ 5579 Stean

Source: Internet
Author: User

Stean Time limit: 1 Second Memory Limit: 65536 KB Special Judge

Tom is good at making Stean, he can make Steans of various color and shape. Now he want to know how many water it can contain, and what many material he need to making a stean.

The shape of the Stean follows rules below:

1. The horizontal projection is a circle. The front projection contains and cosine curve. Tom can pour water from the top of Stean.

2.To describe it more clearly, Tom constructs a cylindrical coordinate system. Tom is a strange person, because if there no stean at all when Z1 Z2 are equal to, he still asks. Tom tells you origin of coordinates was on the axis of cylinder, Z -axis is the axis of cylinder. And he measures that the height of undersurface and the height of upsurface of the Z1 Stean Z2 . And he find the formula of cosine curve is R = 2 + cos ( Z ). Here is the R inner circle ' s radius.

Now your need to tell him the capacity and the area of internal surface, which is in direct proportional to water tank cap Acity and material needed. You need to is precise to the digits after the float point.

Input

The first line of the input contains a single integer T (1 <= T <=), which denotes the number of test CA Ses. Then each line contains a case, consisted by a pair of the integer Z1 numbers Z2 and (| | Z1 <= 1000.00, | Z2 | < ; = 1000.00). They is separated by a space.

Output

There T is lines, each line contains a floating point number, the capacity and the area of internal surface. An answer with absolute error less than 10-2 or with relative error less than 10-5 would be accepted.

Sample Input
20 3.14159-0.0001 0.0
Sample Output
44.41 76.280.00 28.27




Author: WANG, Xinglu

Problem solving: Direct integration, pay attention to the size of $z_1 and z_2$, volume can be negative, surface area cannot be negative
1#include <bits/stdc++.h>2 using namespacestd;3 Const DoublePI = ACOs (-1);4 DoubleFuck (Doublez) {5     returnPi* (4*z +4*sin (z) + z/2+ Sin (2*Z)/4);6 }7 DoubleFDoublez) {8     DoubleTMP =2*pi* (2+ cos (z)) *sqrt (1+ sin (z) *sin (z));9     returntmp;Ten } One DoubleSimpsonDoubleADoubleBintn =10000) { A     Const Doubleh = (b-a)/N; -     Doubleans = f (a) +f (b); -      for(inti =1; I < n; i + =2) ans + =4*f (a+i*h); the      for(inti =2; I < n; i + =2) ans + =2*f (a+i*h); -     returnans*h/3; - } - intMain () { +     Doublez1,z2; -     intKase; +scanf"%d",&Kase); A      while(kase--) { atscanf"%LF%LF",&z1,&z2); -         Doublev = Fuck (z2)-fuck (z1); -         DoubleSS = pi* (2+ cos (z1)) * (2+cos (z1)); -         if(Z1 >z2) Swap (Z1,Z2); -         Doubles = Simpson (Z1,Z2) +SS; -printf"%.10f%.10f\n", v,s); in     } -     return 0; to}
View Code

ZOJ 5579 Stean

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.