結果
問題 | No.2358 xy+yz+zx=N |
ユーザー |
|
提出日時 | 2023-06-23 21:58:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 1,763 ms |
コンパイル使用メモリ | 175,060 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 17:30:59 |
合計ジャッジ時間 | 3,030 ms |
ジャッジサーバーID (参考情報) |
judge4 / 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++; } }