fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. unsigned int n; double s_2, r;
  7. cin >> n;
  8. if ((n < 3) || (n > 5)) cout << "Solution does not exist." << endl;
  9. else
  10. {
  11. s_2 = sin(M_PI/n);
  12. s_2 *= s_2; //Возведение синуса во вторую степень.
  13. r = sqrt(1 - 1/(4.0*s_2));
  14. cout << r << endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 3460KB
stdin
5
stdout
0.525731