結果

問題 No.2358 xy+yz+zx=N
ユーザー 遭難者遭難者
提出日時 2023-06-24 14:56:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 7,299 ms
コンパイル使用メモリ 340,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 10:21:40
合計ジャッジ時間 8,453 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 20 ms
4,380 KB
testcase_09 AC 20 ms
4,380 KB
testcase_10 AC 15 ms
4,376 KB
testcase_11 AC 16 ms
4,380 KB
testcase_12 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define ll long long
using namespace std;
using namespace atcoder;
constexpr int INF = 1e5;
int ans1[INF], ans2[INF], ans3[INF];
void solve()
{
	int n;
	scanf("%d", &n);
	int nn = n / 3;
	int cnt = 0;
	int x = 0, xx = 0;
	while (xx <= nn)
	{
		const int k = n + xx;
		int yy = x << 1, yyy = yy * yy;
		while (yyy <= k)
		{
			if (yy == 0 || k % yy > 0)
			{
				yyy += (yy++ << 1) | 1;
				continue;
			}
			vector<int> per = {x, yy - x, k / yy - x};
			do
			{
				ans1[cnt] = per[0];
				ans2[cnt] = per[1];
				ans3[cnt] = per[2];
				cnt++;
			} while (next_permutation(ALL(per)));
			yyy += (yy++ << 1) | 1;
		}
		xx += (x++ << 1) | 1;
	}
	printf("%d\n", cnt);
	rep(i, cnt) printf("%d %d %d\n", ans1[i], ans2[i], ans3[i]);
	return;
}
int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(13);
	solve();
	return 0;
}
0