結果
問題 | No.2358 xy+yz+zx=N |
ユーザー |
![]() |
提出日時 | 2023-06-23 23:21:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 1,040 bytes |
コンパイル時間 | 1,168 ms |
コンパイル使用メモリ | 122,604 KB |
最終ジャッジ日時 | 2025-02-15 01:36:19 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <algorithm> #include <bit> #include <cassert> #include <cstdio> #include <cstdlib> #include <cmath> #include <deque> #include <iostream> #include <map> #include <random> #include <unordered_set> #include <unordered_map> #include <vector> #include <set> #include <string> using namespace::std; template <typename T> void print(const T& v) { for (const auto& x : v) cout << x << " "; cout << endl; } int main() { ios::sync_with_stdio(false); long long n; cin >> n; set<tuple<int, int, int>> s; for (long long x = 0; 3 * x * x <= n; ++x) for (long long y = max(x, 1ll); 2 * x * y + y * y <= n; ++y) { long long z = (n - x * y) / (x + y); if (x * y + y * z + z * x == n) { s.insert({x, y, z}); s.insert({x, z, y}); s.insert({y, x, z}); s.insert({y, z, x}); s.insert({z, x, y}); s.insert({z, y, x}); } } cout << s.size() << endl; for (const auto& [x, y, z] : s) cout << x << " " << y << " " << z << "\n"; return 0; }