結果

問題 No.1626 三角形の構築
ユーザー bal4ubal4u
提出日時 2021-08-10 21:31:13
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 789 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 33,408 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-20 16:15:36
合計ジャッジ時間 30,769 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,296 KB
testcase_01 AC 1,295 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1,515 ms
5,376 KB
testcase_08 AC 1,605 ms
5,376 KB
testcase_09 TLE -
testcase_10 AC 1,232 ms
5,376 KB
testcase_11 AC 1,897 ms
6,940 KB
testcase_12 AC 316 ms
5,376 KB
testcase_13 AC 730 ms
5,376 KB
testcase_14 AC 1,253 ms
5,376 KB
testcase_15 AC 766 ms
5,376 KB
testcase_16 AC 1,486 ms
5,376 KB
testcase_17 AC 1,300 ms
5,376 KB
testcase_18 AC 1,380 ms
5,376 KB
testcase_19 AC 1,619 ms
5,376 KB
testcase_20 AC 1,690 ms
5,376 KB
testcase_21 AC 1,415 ms
5,376 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

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