結果

問題 No.1626 三角形の構築
ユーザー bal4ubal4u
提出日時 2021-08-11 11:39:48
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 30,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-02 16:10:27
合計ジャッジ時間 1,923 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

typedef long long ll;

int ans[100][3], w;

void check(int T, int a, int b) {
	if (b > 0) {
		int c = T-a-b;
		if (c > 0 && a >= b && a >= c)
			ans[w][0] = a, ans[w][1] = b, ans[w++][2] = c;
	}
}

int main() {
	int N, i, T, t, a;
	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 && (a = t-i) > 0) {
				ll aa = (ll)a*a - 4*(S/i);
				ll a2 = sqrt(aa);
				if (a2*a2 == aa && !((a-a2) & 1))
					check(T, a, t-(a-a2)/2);
			}
		}
		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