結果
問題 | No.2358 xy+yz+zx=N |
ユーザー | HIcoder |
提出日時 | 2023-07-02 00:26:16 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 1,563 bytes |
コンパイル時間 | 970 ms |
コンパイル使用メモリ | 89,816 KB |
実行使用メモリ | 4,864 KB |
最終ジャッジ日時 | 2023-09-22 19:04:16 |
合計ジャッジ時間 | 2,642 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,384 KB |
testcase_07 | AC | 4 ms
4,376 KB |
testcase_08 | AC | 89 ms
4,672 KB |
testcase_09 | AC | 93 ms
4,864 KB |
testcase_10 | AC | 55 ms
4,380 KB |
testcase_11 | AC | 62 ms
4,380 KB |
testcase_12 | AC | 37 ms
4,376 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:69:14: 警告: 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; } }