結果
| 問題 | No.2358 xy+yz+zx=N |
| コンテスト | |
| ユーザー |
applejam
|
| 提出日時 | 2026-01-03 19:28:04 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 94 ms / 2,000 ms |
| コード長 | 1,758 bytes |
| 記録 | |
| コンパイル時間 | 6,659 ms |
| コンパイル使用メモリ | 385,200 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-01-03 19:28:12 |
| 合計ジャッジ時間 | 8,154 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vmi = vector<mint>;
using vvmi = vector<vmi>;
using vvvmi = vector<vvmi>;
#define all(a) (a).begin(), (a).end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
using t = tuple<int, int, int>;
void solve(){
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
set<t> st;
if(n % 3 == 0){
int y = (int)sqrt(n/3);
if(y*y == n/3){
st.insert({y, y, y});
}
}
for(int x = 1; x*x <= n; x++){
int c = n - x*x;
if(c < 0)break;
if(c % (2*x) != 0)continue;
int z = c / (2*x);
if(x == z)continue;
st.insert({x, x, z});
st.insert({x, z, x});
st.insert({z, x, x});
}
for(int x = 0; x*x <= n; x++){
for(int y = x+1; y*y <= n; y++){
int c = n - x*y;
if(c < 0)break;
if(c % (x+y) != 0)continue;
int z = c/(x+y);
if(z <= y)continue;
st.insert({x, y, z});
st.insert({x, z, y});
st.insert({y, x, z});
st.insert({y, z, x});
st.insert({z, x, y});
st.insert({z, y, x});
}
}
cout << st.size() << endl;
for(auto u : st){
auto [a, b, c] = u;
cout << a << " " << b << " " << c << endl;
}
return 0;
}
applejam