結果
問題 | No.2358 xy+yz+zx=N |
ユーザー |
|
提出日時 | 2023-06-23 22:37:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 205,792 KB |
最終ジャッジ日時 | 2025-02-15 01:19:21 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>using namespace std;vector<array<int, 3>> ans, nans;int n;void check(int x, int y) {if ((n - x * y) % (x + y) != 0 || (n - x * y) / (x + y) < y) return;int z = (n - x * y) / (x + y);ans.push_back({ x, y, z });}int main() {ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);cin >> n;for (int x = 0; x * x <= n; x ++) {for (int y = x; y * y <= n; y ++) if (y != 0) {check(x, y);}}for (auto [x, y, z] : ans) {vector<int> arr{ x, y, z };vector<int> p{ 1, 2, 3 };do {nans.push_back({ arr[p[0] - 1], arr[p[1] - 1], arr[p[2] - 1] });} while(next_permutation(p.begin(), p.end()));}sort(nans.begin(), nans.end());nans.erase(unique(nans.begin(), nans.end()), nans.end());cout << nans.size() << "\n";for (auto [x, y, z] : nans) cout << x << " " << y << " " << z << "\n";return 0;}