結果
問題 |
No.2358 xy+yz+zx=N
|
ユーザー |
![]() |
提出日時 | 2023-06-24 14:56:39 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 1,057 bytes |
コンパイル時間 | 7,423 ms |
コンパイル使用メモリ | 342,296 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 17:53:12 |
合計ジャッジ時間 | 8,359 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> #include <atcoder/all> #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(a) a.begin(), a.end() #define ll long long using namespace std; using namespace atcoder; constexpr int INF = 1e5; int ans1[INF], ans2[INF], ans3[INF]; void solve() { int n; scanf("%d", &n); int nn = n / 3; int cnt = 0; 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 { ans1[cnt] = per[0]; ans2[cnt] = per[1]; ans3[cnt] = per[2]; cnt++; } while (next_permutation(ALL(per))); yyy += (yy++ << 1) | 1; } xx += (x++ << 1) | 1; } printf("%d\n", cnt); rep(i, cnt) printf("%d %d %d\n", ans1[i], ans2[i], ans3[i]); return; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(13); solve(); return 0; }