結果

問題 No.2358 xy+yz+zx=N
ユーザー luanmengleiluanmenglei
提出日時 2023-06-23 22:18:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 806 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 201,652 KB
実行使用メモリ 8,028 KB
最終ジャッジ日時 2023-09-14 10:10:23
合計ジャッジ時間 5,941 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 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,380 KB
testcase_07 AC 17 ms
4,376 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<array<int, 3>> ans;
int n;

void check(int x, int z) {
	if ((n - x * z) % (x + z) != 0) return;
	ans.push_back({ x, (n - x * z) / (x + z), z });
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int xz = 1; xz <= n; xz ++) {
		for (int i = 1; i * i <= xz; i ++) if (xz % i == 0) {
			int x = i, z = xz / i;
			check(x, z);
			if (x != z) check(z, x);
		}
	}
	for (int i = 1; i * i <= n; i ++) if (n % i == 0) {
		int a = i, b = n / i;
		ans.push_back({ 0, a, b });
		ans.push_back({ b, a, 0 });
		if (a != b) {
			swap(a, b);
			ans.push_back({ 0, a, b });
			ans.push_back({ b, a, 0 });
		}
	}
	cout << ans.size() << "\n";
	for (auto [x, y, z] : ans) {
		cout << x << " " << y << " " << z << "\n";
	}
	return 0;
}
0