結果
| 問題 | No.1143 面積Nの三角形 |
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2020-07-31 23:00:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 177 ms / 800 ms |
| コード長 | 1,068 bytes |
| 記録 | |
| コンパイル時間 | 2,580 ms |
| コンパイル使用メモリ | 210,264 KB |
| 最終ジャッジ日時 | 2025-01-12 11:21:29 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif
template <class T> vector<T> divisors(T n) {
vector<T> res;
for (T d = 1; d * d <= n; ++d)
if (n % d == 0) res.push_back(d), res.push_back(n / d);
sort(begin(res), end(res));
return {begin(res), unique(begin(res), end(res))};
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int _n;
cin >> _n;
using ll = __int128_t;
ll n = (ll)_n * _n;
auto ds = divisors(n);
vector<tuple<ll, ll, ll>> v;
for (ll s : ds) {
for (ll sa : ds) {
if (sa >= s) break;
if (s > n / sa) break;
ll a = s - sa;
ll x = a * a - 4 * n / (s * sa);
if (x < 0) continue;
ll d = sqrt(x + 0.5);
ll b = ((2 * s - a) - d) / 2, c = ((2 * s - a) + d) / 2;
if (a <= b and c < a + b) {
if (s * (s - a) * (s - b) * (s - c) == n) {
v.emplace_back(a, b, c);
}
}
}
}
sort(begin(v), end(v));
v.erase(unique(begin(v), end(v)), end(v));
cout << size(v) << '\n';
}
risujiroh