結果

問題 No.1626 三角形の構築
ユーザー bal4u
提出日時 2021-08-10 21:31:13
言語 C
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 789 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 31,744 KB
実行使用メモリ 13,648 KB
最終ジャッジ日時 2024-10-12 12:02:12
合計ジャッジ時間 31,126 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 19 TLE * 5 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 1626 三角形の構築
// 2021.8.10

#include <stdio.h>
#include <math.h>

typedef long long ll;
int T, t;
int ans[1000][3], w;

void check(ll s, int k) {
	int i, x = sqrt(s);
	int a = t-k, b, c;
	for (i = k; i <= x; ++i) if (s % i == 0) {
		b = t-i, c = t - s/i;
		if (a+b+c == T) {
			ans[w][0] = a, ans[w][1] = b, ans[w++][2] = c;
		}
	}
}

int main() {
	int N, i;
	ll S;

	scanf("%d", &N);
	while (N--) {
		scanf("%lld%d", &S, &T);
		if (T & 1) { puts("0"); continue; }
		t = T >> 1;
		S *= S;
		if (S % t) { puts("0"); continue; }
		S /= t;
		int x = (int)(pow(S, 1.0/3)+1);
		w = 0;
		for (i = 1; i <= x; ++i) if (S % i == 0) {
			check(S/i, i);
		}
		printf("%d\n", w);
		for (i = 0; i < w; ++i)
			printf("%d %d %d\n",
				ans[i][0], ans[i][1], ans[i][2]);
	}
	return 0;
}
0