fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. void rozwiaz_przypadek() {
  7. double L, dL;
  8. if (!(cin >> L >> dL)) return;
  9.  
  10. double target = L / (L + dL);
  11. double low = 1e-12;
  12. double high = 3.14159265358979323846;
  13.  
  14. for (int i = 0; i < 80; ++i) {
  15. double mid = low + (high - low) / 2.0;
  16. double val = sin(mid) / mid;
  17. if (val < target) {
  18. high = mid;
  19. } else {
  20. low = mid;
  21. }
  22. }
  23.  
  24. double alpha = (low + high) / 2.0;
  25. double h = (L / 2.0) * tan(alpha / 2.0);
  26. cout << (long long)llround(h) << "\n";
  27. }
  28.  
  29. int main() {
  30. ios_base::sync_with_stdio(false);
  31. cin.tie(NULL);
  32.  
  33. int t;
  34. if (cin >> t) {
  35. while (t--) {
  36. rozwiaz_przypadek();
  37. }
  38. }
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 5328KB
stdin
2
1000 20
15000 10
stdout
87
237