【題目敘述】https://zerojudge.tw/ShowProblem?problemid=a995

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main() {
double S;
while (cin >> S){
cout << fixed << setprecision(10);
// r1
cout << sqrt(3.0) / 2.0 * S;
// r2
cout << " " << (2.0 * sqrt(3.0) - 3.0) * S;
// r3
cout << " " << sqrt(3.0) / 4.0 * S;
// r4
double a = 5.0 / 3.0;
double b = 7.0 / sqrt(3.0) * S;
double c = -7.0 / 4.0 * S * S;
cout << " " << (-b + sqrt(b*b - 4.0*a*c)) / (2.0*a);
cout << "\n";
}
return 0;
}
Python code (credit: Amy Chou)
import math
while True:
try:
S = float(input())
r1 = math.sqrt(3) / 2 * S
r2 = (math.sqrt(3) * 2 - 3) * S
r3 = math.sqrt(3) / 4 * S
a = 5 / 3
b = 7 / math.sqrt(3) * S
c = -7 / 4 * S * S
r4 = (-b + math.sqrt(b*b - 4*a*c)) / (2*a)
print(f"{r1:.10f} {r2:.10f} {r3:.10f} {r4:.10f}")
except:
break