結果
問題 |
No.2358 xy+yz+zx=N
|
ユーザー |
|
提出日時 | 2023-11-22 18:56:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 2,256 ms |
コンパイル使用メモリ | 200,704 KB |
最終ジャッジ日時 | 2025-02-17 23:04:54 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; using T=tuple<ll,ll,ll>; int main(){ ll n; cin>>n; set<T> ans; for(ll z=0;z*z<=n;z++){ for(ll y=0;y<=z;y++){ if(y==0&&z==0){ continue; } if((n-y*z)%(y+z)==0){ ll x=(n-y*z)/(y+z); if(x*y+y*z+z*x==n){ if(x==y&&y==z){ ans.insert(T(x,y,z)); }else if(x==y){ ans.insert(T(x,y,z)); ans.insert(T(x,z,y)); ans.insert(T(z,x,y)); }else if(y==z){ ans.insert(T(x,y,z)); ans.insert(T(y,x,z)); ans.insert(T(y,z,x)); }else{ ans.insert(T(x,y,z)); ans.insert(T(x,z,y)); ans.insert(T(y,x,z)); ans.insert(T(y,z,x)); ans.insert(T(z,x,y)); ans.insert(T(z,y,x)); } } } } } cout<<ans.size()<<endl; auto itr=ans.begin(); while(itr!=ans.end()){ cout<<get<0>(*itr)<<" "<<get<1>(*itr)<<" "<<get<2>(*itr)<<endl; itr++; } }