結果
問題 | No.2358 xy+yz+zx=N |
ユーザー |
![]() |
提出日時 | 2023-06-05 14:46:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 19 ms / 2,000 ms |
コード長 | 1,003 bytes |
コンパイル時間 | 2,246 ms |
コンパイル使用メモリ | 199,820 KB |
最終ジャッジ日時 | 2025-02-13 22:54:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ALL(a) a.begin(), a.end() void solve() { int n; cin >> n; int nn = n / 3; vector<tuple<int, int, int>> ans; 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 { ans.push_back({per[0], per[1], per[2]}); } while (next_permutation(ALL(per))); yyy += (yy++ << 1) | 1; } xx += (x++ << 1) | 1; } cout << ans.size() << '\n'; for (auto &[x, y, z] : ans) cout << x << ' ' << y << ' ' << z << '\n'; return; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(13); solve(); return 0; }