結果
問題 | No.2358 xy+yz+zx=N |
ユーザー |
![]() |
提出日時 | 2023-06-30 18:35:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 842 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 63,420 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 06:01:49 |
合計ジャッジ時間 | 2,086 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
/* -*- coding: utf-8 -*-** 2358.cc: No.2358 xy+yz+zx=N - yukicoder*/#include<cstdio>#include<vector>#include<set>#include<algorithm>using namespace std;/* constant *//* typedef */typedef vector<int> vi;typedef set<vi> svi;/* global variables *//* subroutines *//* main */int main() {int n;scanf("%d", &n);svi as;for (int x = 0; x * x * 3 <= n; x++) {int m = n + x * x;for (int p = max(1, x); p * p <= m; p++)if (m % p == 0) {int q = m / p;int y = p - x, z = q - x;if (x <= y && y <= z) {as.insert({x, y, z});as.insert({x, z, y});as.insert({y, x, z});as.insert({y, z, x});as.insert({z, x, y});as.insert({z, y, x});}}}printf("%d\n", (int)as.size());for (auto &v: as)printf("%d %d %d\n", v[0], v[1], v[2]);return 0;}