結果

問題 No.1143 面積Nの三角形
ユーザー risujirohrisujiroh
提出日時 2020-07-31 23:00:41
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 800 ms
コード長 1,068 bytes
コンパイル時間 2,621 ms
コンパイル使用メモリ 216,256 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 01:58:35
合計ジャッジ時間 4,709 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 10 ms
4,376 KB
testcase_08 AC 18 ms
4,376 KB
testcase_09 AC 23 ms
4,376 KB
testcase_10 AC 16 ms
4,376 KB
testcase_11 AC 64 ms
4,376 KB
testcase_12 AC 80 ms
4,380 KB
testcase_13 AC 82 ms
4,376 KB
testcase_14 AC 18 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 165 ms
4,380 KB
testcase_17 AC 169 ms
4,376 KB
testcase_18 AC 146 ms
4,376 KB
testcase_19 AC 131 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
}
0