結果
問題 | No.2358 xy+yz+zx=N |
ユーザー | kotatsugame |
提出日時 | 2023-06-23 21:40:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 537 ms / 2,000 ms |
コード長 | 581 bytes |
コンパイル時間 | 851 ms |
コンパイル使用メモリ | 77,492 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 17:27:44 |
合計ジャッジ時間 | 4,069 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:29:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions] 29 | for(auto[x,y,z]:xyz)cout<<x<<" "<<y<<" "<<z<<"\n"; | ^
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cassert> #include<tuple> using namespace std; vector<tuple<int,int,int> >xyz; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N;cin>>N; {//y=0 or z=0 for(int a=1;a<=N;a++)if(N%a==0) { xyz.push_back(make_tuple(a,N/a,0)); xyz.push_back(make_tuple(a,0,N/a)); } } for(int y=1;y<=N;y++)for(int z=1;y*z<=N;z++) { int rest=N-y*z; if(rest%(y+z)==0) { xyz.push_back(make_tuple(rest/(y+z),y,z)); } } cout<<xyz.size()<<"\n"; for(auto[x,y,z]:xyz)cout<<x<<" "<<y<<" "<<z<<"\n"; }