結果

問題 No.2358 xy+yz+zx=N
ユーザー LeoProLeoPro
提出日時 2023-06-23 21:32:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 998 ms / 2,000 ms
コード長 1,142 bytes
コンパイル時間 2,004 ms
コンパイル使用メモリ 202,444 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 10:02:24
合計ジャッジ時間 7,881 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 997 ms
4,376 KB
testcase_09 AC 998 ms
4,376 KB
testcase_10 AC 994 ms
4,380 KB
testcase_11 AC 994 ms
4,376 KB
testcase_12 AC 765 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#define int long long

using namespace std;
using ll = long long;

void solve();

template<typename ...Args>
void println(Args... args) {
    apply([](auto &&... args) { ((cout << args << ' '), ...); }, tuple(args...));
    cout << '\n';
}

int32_t main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int t = 1;
//    cin >> t;
    for (int tc = 0; tc < t; ++tc) {
        solve();
    }
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<array<int32_t, 3>> res;
    for (int x = 0; 3 * x * x <= n; ++x) {
        for (int y = x + !x; x * y <= n && y <= n; ++y){
            if ((n - x * y) % (x + y)) continue;
            int z = (n - x * y) / (x + y);
            if (z < y) continue;
            array<int32_t, 3> ans{(int32_t)x, (int32_t)y, (int32_t)z};
            do{
                res.push_back(ans);
            } while (next_permutation(ans.begin(), ans.end()));
        }
    }
    cout << res.size() << '\n';
    for (auto [x, y, z] : res) {
        cout << x << ' ' << y << ' ' << z << '\n';
    }
    cout << endl;
}
0