結果

問題 No.1143 面積Nの三角形
ユーザー nikkukunnikkukun
提出日時 2020-08-01 01:08:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 171 ms / 800 ms
コード長 1,242 bytes
コンパイル時間 1,959 ms
コンパイル使用メモリ 168,288 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 04:55:12
合計ジャッジ時間 3,611 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 28 ms
4,380 KB
testcase_08 AC 15 ms
4,376 KB
testcase_09 AC 20 ms
4,380 KB
testcase_10 AC 11 ms
4,376 KB
testcase_11 AC 66 ms
4,376 KB
testcase_12 AC 83 ms
4,380 KB
testcase_13 AC 83 ms
4,384 KB
testcase_14 AC 13 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 169 ms
4,376 KB
testcase_17 AC 171 ms
4,380 KB
testcase_18 AC 147 ms
4,376 KB
testcase_19 AC 132 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tint;

const int N = 1e6 + 5;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

vector<ll> divs;

bool Check(ll a, ll b, ll c) {
	if (a <= 1 || b <= 1 || c <= 1)
		return 0;
	else
		return (a + b > c) && (a + c > b) && (b + c > a);
}

int main() {
	ios::sync_with_stdio(0);

	ll n;
	cin >> n;
	n = n * n;

	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divs.push_back(i);
			if (n != i * i)
				divs.push_back(n / i);
		}
	}

	int ans = 0;
	for (auto x: divs)
		for (auto y: divs) {
			ll xyMul = x * y;
			ll xyAdd = x + y;
			if (4 * n % xyMul) continue;
			ll tmp1 = xyAdd * xyAdd + 4 * n / xyMul;
			ll rt = sqrt(tmp1);
			if (rt * rt != tmp1) continue;
			ll tmp2 = rt - xyAdd;
			if (tmp2 % 2 != 0) continue;

			ll z = tmp2 / 2;
			ll s = x + y + z;
			ll a = s - x;
			ll b = s - y;
			ll c = s - z;

			ans += (Check(a, b, c) && x >= y && y >= z);
		}

	cout << ans << endl;

	return 0;
}
0