結果
問題 | No.2953 Maximum Right Triangle |
ユーザー |
![]() |
提出日時 | 2024-11-08 21:54:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,960 bytes |
コンパイル時間 | 2,928 ms |
コンパイル使用メモリ | 249,948 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 21:54:59 |
合計ジャッジ時間 | 3,400 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 6 |
ソースコード
#if __INCLUDE_LEVEL__ == 0#include __BASE_FILE__void Solve() {int64_t D, x, y;IN(D, x, y);int64_t ans = 0;for (int _ : Rep(0, 2)) {int64_t g = gcd(x, y);int64_t x2 = x / g;int64_t y2 = y / g;int64_t c = INF64;if (x2 > 0) {SetMin(c, (D - y) / x2);}if (y2 > 0) {SetMin(c, x / y2);}assert(c < INF64);int64_t cur = x2 * x2 + y2 * y2;cur *= g;cur *= c;SetMax(ans, cur);swap(x, y);}OUT(ans);}int main() {ios::sync_with_stdio(false);cin.tie(nullptr);int t;IN(t);while (t--) {Solve();}}#elif __INCLUDE_LEVEL__ == 1#include <bits/stdc++.h>template <class T> concept Range = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;template <class T> concept Tuple = std::__is_tuple_like<T>::value && !Range<T>;namespace std {istream& operator>>(istream& is, Range auto&& r) {for (auto&& e : r) is >> e;return is;}istream& operator>>(istream& is, Tuple auto&& t) {apply([&](auto&... xs) { (is >> ... >> xs); }, t);return is;}ostream& operator<<(ostream& os, Range auto&& r) {auto sep = "";for (auto&& e : r) os << exchange(sep, " ") << e;return os;}ostream& operator<<(ostream& os, Tuple auto&& t) {auto sep = "";apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t);return os;}} // namespace stdusing namespace std;#define _ _ [[maybe_unused]]#define LAMBDA2(x, y, ...) ([&](auto&& x, auto&& y) -> decltype(auto) { return __VA_ARGS__; })#define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__)#define SetMin(...) LAMBDA2(x, y, y < x && (x = y, 1))(__VA_ARGS__)#define SetMax(...) LAMBDA2(x, y, x < y && (x = y, 1))(__VA_ARGS__)#define INF64 (INT64_MAX / 2)#define IN(...) (cin >> forward_as_tuple(__VA_ARGS__))#define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n')#endif // __INCLUDE_LEVEL__ == 1