結果
| 問題 |
No.2953 Maximum Right Triangle
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-11-10 00:50:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,246 bytes |
| コンパイル時間 | 2,068 ms |
| コンパイル使用メモリ | 194,304 KB |
| 最終ジャッジ日時 | 2025-02-25 03:24:36 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 3 RE * 3 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/modint>
using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint998244353;
//calculate ceil(a/b)
template<typename T>
T ceil(T a, T b){
assert(b != 0);
if (a == 0) return 0;
if (a > 0 && b > 0) return (a+b-1) / b;
else if (a < 0 && b < 0) return (a+b+1) / b;
else return a / b;
}
//calculate floor(a/b)
template<typename T>
T floor(T a, T b){
assert(b != 0);
if (a == 0) return 0;
if (a > 0 && b < 0) return (a-b-1) / b;
else if (a < 0 && b > 0) return (a-b+1) / b;
else return a / b;
}
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int T;
cin >> T;
while(T--){
ll D, x, y, l1, r1, l2, r2, l, r;
cin >> D >> x >> y;
//ありうるのは(x-ny, y+nx) (nは整数)
//面積の2倍は|n|(x^2+y^2)
//0<=x-ny<=D, 0<=y+nx<=D
l1 = ceil(x-D, y);
r1 = floor(x, y);
l2 = ceil(-y, x);
r2 = floor(D-y, x);
l = max(l1, l2);
r = min(r1, r2);
if (l>r){
cout << 0 << endl;
}
else{
cout << max(abs(l),abs(r)) * (x*x+y*y) << endl;
}
}
return 0;
}
srjywrdnprkt