結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
遭難者
|
| 提出日時 | 2023-04-16 12:23:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 1,402 bytes |
| コンパイル時間 | 4,272 ms |
| コンパイル使用メモリ | 259,552 KB |
| 最終ジャッジ日時 | 2025-02-12 09:08:21 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define ll long long
#define pii pair<int, int>
#define pil pair<int, ll>
void chmax(ll &x, ll y)
{
if (x < y)
x = y;
}
ll mp(ll a, ll b, ll m)
{
if (b == 0)
return 1;
if (b & 1)
return mp(a * a % m, b / 2, m);
return a * mp(a, b - 1, m) % m;
}
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;
}
sort(ALL(ans));
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;
}
遭難者