結果
問題 | No.2358 xy+yz+zx=N |
ユーザー |
![]() |
提出日時 | 2023-06-23 22:38:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 927 ms / 2,000 ms |
コード長 | 929 bytes |
コンパイル時間 | 3,120 ms |
コンパイル使用メモリ | 258,360 KB |
実行使用メモリ | 8,480 KB |
最終ジャッジ日時 | 2024-07-01 17:39:54 |
合計ジャッジ時間 | 8,343 ms |
ジャッジサーバー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";}}