結果
問題 |
No.2358 xy+yz+zx=N
|
ユーザー |
|
提出日時 | 2023-07-02 00:26:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 1,563 bytes |
コンパイル時間 | 888 ms |
コンパイル使用メモリ | 91,908 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-08 10:13:30 |
合計ジャッジ時間 | 1,842 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:69:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 69 | for(auto [x,y,z]:ans){ | ^
ソースコード
#include<iostream> #include<set> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<numeric> #include<queue> #include<cmath> using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair<int,int> P; typedef pair<int,P> PP; const ll MOD=1e9+7; int main(){ ll N; cin>>N; typedef tuple<ll,ll,ll> TP; vector<TP> ans; for(ll x=0;3*x*x<=N;x++){ for(ll y=x;y*y+2*x*y<=N;y++){ ll c=N-x*y; if(c<0) continue; if((x+y)==0) continue; if(c%(x+y)==0){ ll z=c/(x+y); if(y>z) continue; //x<=y<=z vector<ll> vec={x,y,z}; if(x!=y && y!=z && z!=x ){ do{ ans.emplace_back(vec[0],vec[1],vec[2]); }while(next_permutation(vec.begin(),vec.end())); } else if(x==y && y!=z){ ans.emplace_back(x,y,z); ans.emplace_back(x,z,y); ans.emplace_back(z,x,y); }else if(x!=y && y==z){ ans.emplace_back(x,y,z); ans.emplace_back(z,x,y); ans.emplace_back(z,y,x); }else{ //x==y==z ans.emplace_back(x,y,z); } } } } cout<<ans.size()<<endl; for(auto [x,y,z]:ans){ cout<<x<<' '<<y<<' '<<z<<endl; } }