結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-07 17:32:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 121 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 4,377 ms |
| コンパイル使用メモリ | 256,144 KB |
| 最終ジャッジ日時 | 2025-02-20 22:45:52 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;
ll N, x, y, z;
vector<vector<ll>> vec, ans;
int main() {
cin >> N;
for (x = 0; x * x <= N; x++) {
for (y = x; y * y <= N; y++) {
if (x == 0 && y == 0) continue;
z = (N - x * y) / (x + y);
if ((N - x * y) % (x + y) == 0 && z >= y) {
vec.push_back({x, y, z});
}
}
}
for (auto p: vec) {
sort(p.begin(), p.end());
do {
ans.push_back({p[0], p[1], p[2]});
} while (next_permutation(p.begin(), p.end()));
}
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++) {
cout << ans[i][0] << ' ' << ans[i][1] << ' ' << ans[i][2] << endl;
}
return 0;
}