結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-23 22:38:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 924 ms / 2,000 ms |
| コード長 | 928 bytes |
| コンパイル時間 | 2,148 ms |
| コンパイル使用メモリ | 205,500 KB |
| 最終ジャッジ日時 | 2025-02-15 01:20:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll N; cin >> N;
vector<tuple<ll, ll, ll>> ans;
auto push = [&](ll a, ll b, ll c) {
ans.push_back({a, b, c});
ans.push_back({a, c, b});
ans.push_back({b, a, c});
ans.push_back({b, c, a});
ans.push_back({c, a, b});
ans.push_back({c, b, a});
};
for (int i = 1; i * i <= N; i++) {
if (N % i != 0) continue;
int j = N / i;
push(0, i, j);
}
for (ll x = 1; x <= N; x++) {
for (ll y = x; x * y <= N; y++) {
if ((N - x * y) % (x + y) != 0) continue;
ll z = (N - x * y) / (x + y);
push(x, y, z);
}
}
sort(ans.begin(), ans.end());
vector<tuple<ll, ll, ll>> n;
for (auto p : ans) {
if (n.size() == 0 || n.back() != p) {
n.push_back(p);
}
}
cout << n.size() << "\n";
for (auto [x, y, z] : n) {
cout << x << " " << y << " " << z << "\n";
}
}