結果

問題 No.2358 xy+yz+zx=N
ユーザー elphe
提出日時 2024-07-17 12:42:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 736 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 74,972 KB
最終ジャッジ日時 2025-02-23 16:05:30
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, x, y, z_l, z_r, z_c;
	cin >> N;
	vector<tuple<int, int, int>> ans;

	for (x = 0; x <= N; ++x)
		for (y = 0; y <= N && x * y <= N; ++y)
			for (z_l = 0, z_r = N; z_l <= z_r; )
			{
				z_c = (z_l + z_r) / 2;
				if (x * y + z_c * static_cast<long long>(x + y) < N)
					z_l = z_c + 1;
				else if (x * y + z_c * static_cast<long long>(x + y) != N)
					z_r = z_c - 1;
				else
					ans.emplace_back(x, y, z_c), z_r = -1;
			}

	cout << ans.size() << '\n';
	for (x = 0; x != ans.size(); ++x)
		cout << get<0>(ans[x]) << ' ' << get<1>(ans[x]) << ' ' << get<2>(ans[x]) << '\n';

	return 0;
}
0