結果
| 問題 | No.2358 xy+yz+zx=N |
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-06-23 21:30:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 985 ms / 2,000 ms |
| コード長 | 1,032 bytes |
| コンパイル時間 | 4,373 ms |
| コンパイル使用メモリ | 262,240 KB |
| 最終ジャッジ日時 | 2025-02-15 00:38:11 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef modint998244353 mint;
typedef long long ll;
// defcomp
template <typename T>
vector<T> compress(vector<T> &X) {
vector<T> vals = X;
sort(vals.begin(), vals.end());
vals.erase(unique(vals.begin(), vals.end()), vals.end());
return vals;
}
// -----
int main(){
vector<tuple<int,int,int>> ans;
ll n; cin >> n;
for (ll a=0; a<=n; a++){
if (a*a*3 > 2*n) break;
for (ll b=a; b<=n; b++){
if (a + b == 0){
continue;
}
if (n - a*b < 0) break;
if ((n - a*b) % (a+b) != 0) continue;
ll c = (n - a*b)/(a+b);
ans.push_back(tuple(a, b, c));
ans.push_back(tuple(a, b, c));
ans.push_back(tuple(b, a, c));
ans.push_back(tuple(b, c, a));
ans.push_back(tuple(c, a, b));
ans.push_back(tuple(c, b, a));
}
}
vector<tuple<int,int,int>> ret = compress(ans);
int m = ret.size();
cout << m << "\n";
for (int i=0; i<m; i++){
auto [x,y,z] = ret[i];
cout << x << " " << y << " " << z << "\n";
}
}
shobonvip