結果

問題 No.2358 xy+yz+zx=N
ユーザー 遭難者遭難者
提出日時 2023-06-06 21:10:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,030 bytes
コンパイル時間 2,882 ms
コンパイル使用メモリ 205,944 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 10:01:33
合計ジャッジ時間 4,641 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ALL(a) a.begin(), a.end()
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;
    }
    cout << ans.size() << '\n';
    for (auto &[x, y, z] : ans)
        cout << x << ' ' << y << ' ' << z << '\n';
    cout << "^_^" << '\n';
    return;
}
int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(13);
    solve();
    return 0;
}
0