結果

問題 No.2358 xy+yz+zx=N
ユーザー jabeejabee
提出日時 2023-06-23 22:22:17
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 833 ms / 2,000 ms
コード長 2,637 bytes
コンパイル時間 10,675 ms
コンパイル使用メモリ 151,020 KB
実行使用メモリ 5,644 KB
最終ジャッジ日時 2023-09-14 10:11:29
合計ジャッジ時間 11,888 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 831 ms
5,644 KB
testcase_09 AC 833 ms
5,644 KB
testcase_10 AC 826 ms
4,376 KB
testcase_11 AC 826 ms
4,492 KB
testcase_12 AC 633 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <atcoder/all>
#include <atcoder/dsu>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <atcoder/scc>
#include <chrono>
#include <random>
#include <cassert>
#ifndef templete
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
 
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;
using namespace atcoder;
//using atmint = modint998244353;
using atmint = modint;
using Graph = vector<vector<int>>;
using P = pair<long long,long long>;
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
 
//---------------------------------------------------------------------------------------------------

#endif // templete
//---------------------------------------------------------------------------------------------------
void _main() {   
    ll n;
    cin >> n;
    vector<vector<ll>>ans;
    for(ll x = 1; x <= n; x++){
        ll maxy = n / x;
        for(ll y = 1; y <= maxy; y++){
            ll r = n - x * y;
            ll l = x + y;
            ll z = r / l;
            if(z == 0)continue;
            if(r % l != 0)continue;
            ans.push_back({x,y,z});
           // if(r % l == 0)ans.emplace_back(x,y,z);
           //if(r % l == 0)ans.push_back({x,y,z});
        }
    }
    for(ll y = 1; y <= n; y++){
        if(n % y == 0){
            /*
            ans.emplace_back(0,y,n/y);
            ans.emplace_back(n/y,0,y);
            ans.emplace_back(y,n/y,0);
            */
           ans.push_back({0,y,n/y});
            ans.push_back({n/y,0,y});
            ans.push_back({y,n/y,0});
        }
    }
    /*
    for(ll z = 1; z <= n; z++){
        if(n % z == 0)ans.emplace_back(n/z,0,z);
    }
    for(ll x = 1; x <= n; x++){
        if(n % x == 0)ans.emplace_back(x,n/x,0);
    }
    */
    cout << ans.size() << endl;
    rep(i,0,ans.size()){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << "\n"; 
        /*
        ll x;
        ll y;
        ll z;
        tie(x,y,z) = ans[i];
        cout << x << " " << y << " " << z << "\n"; 
        */
    }

}
0