結果

問題 No.2358 xy+yz+zx=N
ユーザー tsugutsugutsugutsugu
提出日時 2023-06-23 21:58:20
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 2,912 ms
コンパイル使用メモリ 253,000 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2023-09-14 10:07:09
合計ジャッジ時間 4,211 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,380 KB
testcase_01 AC 8 ms
4,376 KB
testcase_02 AC 8 ms
4,376 KB
testcase_03 AC 8 ms
4,376 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 8 ms
4,380 KB
testcase_07 AC 10 ms
4,376 KB
testcase_08 AC 62 ms
5,628 KB
testcase_09 AC 64 ms
6,016 KB
testcase_10 AC 45 ms
4,380 KB
testcase_11 AC 48 ms
4,692 KB
testcase_12 AC 39 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 1
#endif

const int MX = 3300;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    set<tuple<int, int, int>> A;
    for (int x = 0; x <= MX; x++) {
        for (int y = 0; y <= MX; y++) {
            if (x == 0 && y == 0) {
                continue;
            }
            if (n - x * y < 0) {
                continue;
            }
            if ((n - x * y) % (x + y) == 0) {
                int z = (n - x * y) / (x + y);
                A.insert(make_tuple(x, y, z));
                A.insert(make_tuple(x, z, y));
                A.insert(make_tuple(y, x, z));
                A.insert(make_tuple(y, z, x));
                A.insert(make_tuple(z, x, y));
                A.insert(make_tuple(z, y, x));
            }
        }
    }
    vector<tuple<int, int, int>> ans(A.begin(), A.end());
    cout << ans.size() << '\n';
    for (int i = 0; i < (int) ans.size(); i++) {
        cout << get<0>(ans[i]) << ' ' << get<1>(ans[i]) << ' ' << get<2>(ans[i]) << '\n';
    }
}
0