結果

問題 No.2358 xy+yz+zx=N
ユーザー pointNpointN
提出日時 2023-06-23 21:47:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,485 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 141,288 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-14 10:04:51
合計ジャッジ時間 12,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 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 7 ms
4,380 KB
testcase_08 TLE -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 1,568 ms
4,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N; cin >> N;
  set<vector<ll>> st;
  // x<=y<=z
  for(ll z=0;z<=N;z++){
    for(ll y=0;y*z<=N && y<=N;y++){
      if(y+z==0) continue;
      ll r = N-(y*z);
      if(r>=0){
        if(r%(y+z)==0 && r/(y+z)<=y){
          ll x = r/(y+z);
          st.insert({x,y,z});
        }
      }
      else break;
    }
  }
  set<vector<ll>> ans;
  for(auto s:st){
    vector<int> v(3); rep(i,3) v[i]=i;
    do{
      vector<ll> a = {s[v[0]],s[v[1]],s[v[2]]};
      ans.insert(a);
    }while(next_permutation(v.begin(), v.end()));
  }
  int T = sz(ans);
  cout << T << '\n';
  for(auto a:ans){
    cout << a[0] << ' ' << a[1] << ' ' << a[2] << '\n';
  }
  return 0;
};
0