結果

問題 No.2358 xy+yz+zx=N
ユーザー nemutainemutai
提出日時 2023-06-23 22:40:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 1,065 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 206,408 KB
実行使用メモリ 5,880 KB
最終ジャッジ日時 2023-09-14 10:13:59
合計ジャッジ時間 3,983 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 190 ms
5,776 KB
testcase_09 AC 195 ms
5,880 KB
testcase_10 AC 141 ms
4,380 KB
testcase_11 AC 150 ms
4,472 KB
testcase_12 AC 102 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define all(v) v.begin(),v.end()
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
using vp=vector<pair<ll, ll>>;

const ll INF=1ll<<60;
ll mod10=1e9+7;
ll mod99=998244353;
const double PI = acos(-1);

#define rep(i,n) for (ll i=0;i<n;++i)
#define per(i,n) for(int i=n-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=a;i<n;++i)
#define per2(i,a,n) for (ll i=a;i>=n;--i)

int main(){
    ll N;
    cin>>N;
    set<tuple<ll,ll,ll>> st;
    rep2(i,0,N+1){
        if(i*i>N)break;
        rep2(j,1,N+1){
            if(j*j>N)break;
            if((N-i*j)%(i+j)==0){
                ll z=(N-i*j)/(i+j);
                st.emplace(i,j,z);
                st.emplace(i,z,j);
                st.emplace(j,i,z);
                st.emplace(j,z,i);
                st.emplace(z,i,j);
                st.emplace(z,j,i);
                
            }
        }
    }
    cout << st.size() << endl;
    for(auto [x,y,z]:st) cout<<x<<" "<<y<<" "<<z<<endl;
}
0