Problem D
Input: standard input
Output: standard output
Time Limit: 2 seconds
Memory Limit: 32 MB
You are asked to place the largest possible square inside a regular pentagon (whose internal angles are same and all the sides are same in length). You are given the information that one vertex of the square will be coincident with a vertex of the square as shown in the figure below. You will have to find the length of a side of the square when a side of the regular pentagon is given.
Input
The input file contains several lines of input. Each line contains a floating point number F (0<=F<=100000) which indicates the length of a side of the pentagon. Input is terminated by end of file.
Output
For each line of input produce one line of output containing a floating point number with ten digits after the decimal point. This number indicates the largest possible side of a square that fits in the pentagon. This output will be judged with a special correction program, so don’t worry about small precision errors.
Sample Input
0.0000001
0.0000002
0.0000003
Sample Output
0.0000001067
0.0000002135
0.0000003202
(World Finals Warm-up Contest, Problem Setter: Shahriar Manzoor)
#include <iostream> #include <cmath> #include <iomanip> using namespace std; const double PI = 3.14159265359; class TroubleWithAPentagon{ private: double length; double side; public: void initialize(double l){length = l;} void computing(){side = length * sin(108 * PI / 180) / sin(63 * PI / 180);} void outResult(){cout << setiosflags(ios::fixed) << setprecision(10) << side << endl;} }; int main(){ TroubleWithAPentagon twap; double l; while(cin >> l){ twap.initialize(l); twap.computing(); twap.outResult(); } return 0; }
浙公网安备 33010602011771号