結果

問題 No.2358 xy+yz+zx=N
ユーザー yansi819yansi819
提出日時 2024-04-07 17:32:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 799 bytes
コンパイル時間 4,488 ms
コンパイル使用メモリ 269,056 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-07 17:32:48
合計ジャッジ時間 6,487 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 5 ms
6,676 KB
testcase_08 AC 116 ms
6,676 KB
testcase_09 AC 122 ms
6,676 KB
testcase_10 AC 82 ms
6,676 KB
testcase_11 AC 88 ms
6,676 KB
testcase_12 AC 59 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

ll N, x, y, z;
vector<vector<ll>> vec, ans;

int main() {
  cin >> N;
  for (x = 0; x * x <= N; x++) {
    for (y = x; y * y <= N; y++) {
      if (x == 0 && y == 0) continue;
      z = (N - x * y) / (x + y);
      if ((N - x * y) % (x + y) == 0 && z >= y) {
        vec.push_back({x, y, z});
      }
    }
  }
  for (auto p: vec) {
    sort(p.begin(), p.end());
    do {
      ans.push_back({p[0], p[1], p[2]});
    } while (next_permutation(p.begin(), p.end()));
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i][0] << ' ' << ans[i][1] << ' ' << ans[i][2] << endl;
  }
  return 0;
}
0