Language: C++


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>&#8232;using namespace std;

#define rep(i,n) for (int i = 0; i < int(n); i++)
#define all(c) (c).begin(), (c).end()

int h, w;

int main(int argc, const char * argv[]) {
    while (cin >> h >> w && h > 0 && w > 0) {
        priority_queue<pair<int, int>> pq;
        pair<int, int> p = { - w*w - h*h, - h };
        rep (x,151) rep (y,151) {
            if (x > 0 && y > 0 && x > y) {
                pair<int, int> q = { - x*x - y*y, - y };
                if (p > q) pq.push(q);
            }
        }
        pair<int, int> q = pq.top();
        cout << -q.second << " " << sqrt(-q.first-q.second*q.second) << endl;
    }
}

Compiler output:
a.cc:6:17: warning: extra tokens at end of #include directive
    6 | #include <cmath>&#8232;using namespace std;
      |                 ^
a.cc: In function 'int main(int, const char**)':
a.cc:14:12: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   14 |     while (cin >> h >> w && h > 0 && w > 0) {
      |            ^~~
      |            std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:15:9: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'?
   15 |         priority_queue<pair<int, int>> pq;
      |         ^~~~~~~~~~~~~~
      |         std::priority_queue
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_queue.h:496:11: note: 'std::priority_queue' declared here
  496 |     class priority_queue
      |           ^~~~~~~~~~~~~~
a.cc:15:24: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   15 |         priority_queue<pair<int, int>> pq;
      |                        ^~~~
      |                        std::pair
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:15:29: error: expected primary-expression before 'int'
   15 |         priority_queue<pair<int, int>> pq;
      |                             ^~~
a.cc:16:14: error: expected primary-expression before 'int'
   16 |         pair<int, int> p = { - w*w - h*h, - h };
      |              ^~~
a.cc:19:22: error: expected primary-expression before 'int'
   19 |                 pair<int, int> q = { - x*x - y*y, - y };
      |                      ^~~
a.cc:20:21: error: 'p' was not declared in this scope
   20 |                 if (p > q) pq.push(q);
      |                     ^
a.cc:20:25: error: 'q' was not declared in this scope
   20 |                 if (p > q) pq.push(q);
      |                         ^
a.cc:20:28: error: 'pq' was not declared in this scope
   20 |                 if (p > q) pq.push(q);
      |                            ^~
a.cc:23:14: error: expected primary-expression before 'int'
   23 |         pair<int, int> q = pq.top();
      |              ^~~
a.cc:24:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   24 |         cout << -q.second << " " << sqrt(-q.first-q.second*q.second) << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:24:18: error: 'q' was not declared in this scope
   24 |         cout << -q.second << " " << sqrt(-q.first-q.second*q.second) << endl;
      |                  ^
a.cc:24:73: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   24 |         cout << -q.second << " " << sqrt(-q.first-q.second*q.second) << endl;
      |                                                                         ^~~~
      |                                                                         std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~