結果

問題 No.2358 xy+yz+zx=N
ユーザー HIcoderHIcoder
提出日時 2023-07-02 00:25:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,463 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 107,504 KB
実行使用メモリ 5,024 KB
最終ジャッジ日時 2023-09-22 19:03:13
合計ジャッジ時間 2,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 91 ms
5,024 KB
testcase_09 AC 92 ms
4,736 KB
testcase_10 AC 55 ms
4,376 KB
testcase_11 AC 63 ms
4,380 KB
testcase_12 AC 38 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);

                }

            }
        }
    }

    cout<<ans.size()<<endl;
    for(auto [x,y,z]:ans){
        cout<<x<<' '<<y<<' '<<z<<endl;
    }
    
}
0