fork download
  1. #include <boost/multiprecision/cpp_dec_float.hpp>
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6. namespace mp = boost::multiprecision;
  7. using Real = mp::number<mp::cpp_dec_float<1024>>;
  8.  
  9. template<class T> T next_value(T val){
  10. T res, x = 0, y = val, z;
  11.  
  12. while(x != y){
  13. z = (x+y) / 2;
  14. if(val + z != val){
  15. res = val + z;
  16. y = z;
  17. } else {
  18. x = y;
  19. }
  20. }
  21.  
  22. return res;
  23. }
  24.  
  25. int main(){
  26. int x1 = -1e9, y1 = 1e9-1;
  27. int x2 = 1e9-1, y2 = -1e9+2;
  28.  
  29. cout << "(" << x1 << "," << y1 << ")" << endl;
  30. cout << "(" << x2 << "," << y2 << ")" << endl;
  31. cout << (long long) x1 * y2 - (long long) x2 * y1 << endl << endl;;
  32.  
  33. double tan1 = atan2((double)y1, (double)x1);
  34. double tan2 = atan2((double)y2, (double)x2) + 2 * acos((double)0);
  35.  
  36. cout << setprecision(30) << fixed;
  37.  
  38. cout << tan1 << " " << next_value(tan1) << endl;
  39. cout << tan2 << " " << next_value(tan2) << endl;
  40.  
  41. long double tan1ld = atan2((long double)y1, (long double)x1);
  42. long double tan2ld = atan2((long double)y2, (long double)x2) + 2 * acos((long double)0);
  43.  
  44. cout << tan1ld << " " << next_value(tan1ld) << endl;
  45. cout << tan2ld << " " << next_value(tan2ld) << endl;
  46.  
  47. Real tan1lld = atan2((Real)y1, (Real)x1);
  48. Real tan2lld = atan2((Real)y2, (Real)x2) + 2 * acos((Real)0);
  49.  
  50. cout << tan1lld << " " << next_value(tan1lld) << endl;
  51. cout << tan2lld << " " << next_value(tan2lld) << endl;
  52.  
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 0.15s 4388KB
stdin
Standard input is empty
stdout
(-1000000000,999999999)
(999999999,-999999998)
-1

2.356194490692344878368658100953 2.356194490692345322457867951016
2.356194490692344878368658100953 2.356194490692345322457867951016
2.356194490692344929109319773275 2.356194490692344929326160207772
2.356194490692344929543000642269 2.356194490692344929759841076766
2.356194490692344929096982537543 2.356194490692344929096982537543
2.356194490692344929596982538543 2.356194490692344929596982538543