結果
| 問題 | No.2358 xy+yz+zx=N |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-05 09:58:13 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 876 bytes |
| 記録 | |
| コンパイル時間 | 3,383 ms |
| コンパイル使用メモリ | 344,824 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-03-05 10:07:42 |
| 合計ジャッジ時間 | 4,131 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N;
cin >> N;
set<tuple<ll,ll,ll>> st;
for (ll y = 1; y * y <= N; y++) {
for (ll x = 0; x <= y; x++) {
ll rem = N - x * y;
// z >= y でないと x <= y <= z を満たさない
if (rem < y * (x + y)) break;
if (rem % (x + y) == 0) {
ll z = rem / (x + y);
st.insert({x, y, z});
st.insert({x, z, y});
st.insert({y, x, z});
st.insert({y, z, x});
st.insert({z, x, y});
st.insert({z, y, x});
}
}
}
cout << st.size() << '\n';
for (const auto& [a, b, c] : st) {
cout << a << ' ' << b << ' ' << c << '\n';
}
}