結果
| 問題 |
No.2358 xy+yz+zx=N
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-23 21:47:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,485 bytes |
| コンパイル時間 | 1,658 ms |
| コンパイル使用メモリ | 137,232 KB |
| 最終ジャッジ日時 | 2025-02-15 00:52:56 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 4 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
int main(){
ll N; cin >> N;
set<vector<ll>> st;
// x<=y<=z
for(ll z=0;z<=N;z++){
for(ll y=0;y*z<=N && y<=N;y++){
if(y+z==0) continue;
ll r = N-(y*z);
if(r>=0){
if(r%(y+z)==0 && r/(y+z)<=y){
ll x = r/(y+z);
st.insert({x,y,z});
}
}
else break;
}
}
set<vector<ll>> ans;
for(auto s:st){
vector<int> v(3); rep(i,3) v[i]=i;
do{
vector<ll> a = {s[v[0]],s[v[1]],s[v[2]]};
ans.insert(a);
}while(next_permutation(v.begin(), v.end()));
}
int T = sz(ans);
cout << T << '\n';
for(auto a:ans){
cout << a[0] << ' ' << a[1] << ' ' << a[2] << '\n';
}
return 0;
};