結果
問題 |
No.2358 xy+yz+zx=N
|
ユーザー |
|
提出日時 | 2023-06-23 22:18:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 806 bytes |
コンパイル時間 | 1,977 ms |
コンパイル使用メモリ | 196,384 KB |
最終ジャッジ日時 | 2025-02-15 01:09:51 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 1 -- * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; vector<array<int, 3>> ans; int n; void check(int x, int z) { if ((n - x * z) % (x + z) != 0) return; ans.push_back({ x, (n - x * z) / (x + z), z }); } int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n; for (int xz = 1; xz <= n; xz ++) { for (int i = 1; i * i <= xz; i ++) if (xz % i == 0) { int x = i, z = xz / i; check(x, z); if (x != z) check(z, x); } } for (int i = 1; i * i <= n; i ++) if (n % i == 0) { int a = i, b = n / i; ans.push_back({ 0, a, b }); ans.push_back({ b, a, 0 }); if (a != b) { swap(a, b); ans.push_back({ 0, a, b }); ans.push_back({ b, a, 0 }); } } cout << ans.size() << "\n"; for (auto [x, y, z] : ans) { cout << x << " " << y << " " << z << "\n"; } return 0; }