fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. using namespace __gnu_pbds; // needed for tree + PBDS
  6.  
  7. #define pb push_back
  8. #define all(x) x.begin(), x.end()
  9. typedef long long ll;
  10. const ll INF = (ll)1e18;
  11. const ll MOD = 998244353;
  12. const double eps = 1e-6 ;
  13. template <class T>
  14. using ordered_set = tree<
  15. T,
  16. null_type,
  17. less<T>,
  18. rb_tree_tag,
  19. tree_order_statistics_node_update
  20. >;
  21. void solve() {
  22. ll a , b ; cin >> a >> b ;
  23. ll x = (a+4)/2 , y = a+b ;
  24. ll delta = x*x - 4 * y ;
  25. long double r = sqrtl(delta ) ;
  26. cout << r <<endl ;
  27. cout << x << " " << y << " " << delta <<" " << r << endl ;
  28. long double test1 = (-x-r)/2 , test2 = (-x+r)/2 ;
  29. ll ans = 2e9 ;
  30. cout << test1 <<" " << test2 << endl ;
  31. ll test11 = test1 , test22 = test2 ;
  32. if (fabsl(test11 - test1) <=eps && test1 > 0 ) {
  33. ans = min (ans ,test11 ) ;
  34. cout << test11 << "hhh" << endl ;
  35. }
  36. if (fabsl(test22 - test2) <=eps && test2 > 0 ) {
  37. ans = min (ans ,test22) ;
  38. cout << test22 << "hhh" << endl ;
  39. }
  40. ll n = (a+ 4) /2 - ans ;
  41. cout << n << " " << ans << endl ;
  42. }
  43.  
  44. int main() {
  45. ios::sync_with_stdio(false);
  46. cin.tie(nullptr);
  47. #ifndef ONLINE_JUDGE
  48. freopen("input.txt", "r", stdin);
  49. freopen("output.txt", "w", stdout);
  50. #endif
  51. int t = 1 ; cin >> t;
  52. int maxi = 200000 + 5;
  53. while (t--) solve();
  54. return 0;
  55. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1.97322e+09
11194332109209 22388664218415 3893611758173614261 1.97322e+09
-5.59815e+12 -5.59618e+12
11192332109209 2000000000