結果

問題 No.2358 xy+yz+zx=N
ユーザー Ywestbuilderk
提出日時 2024-03-16 17:02:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 204,492 KB
最終ジャッジ日時 2025-02-20 06:54:05
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using T = array<int,3>;
int main(){
	int n;
    cin >> n;
    int n1 = n / 3;
    set<T> s;
    for(int i = 1;i * i <= n;i++){
    	if(n % i == 0) s.insert(T{0,i,n / i});
    }
    for(int i = 1;i * i <= n1;i++){
    	for(int j = i;i * j <= n1;j++){
    		int an = n - i * j;
    		if(an % (i + j) == 0 and j <= an / (i + j)) s.insert(T{i,j,an / (i + j)});
    	}
    }
    vector<T> ans;
    for(T z : s){
      T z1 = z;
      set<T> s1;
      s1.insert(T{z1[0],z1[1],z1[2]});
      s1.insert(T{z1[0],z1[2],z1[1]});
      s1.insert(T{z1[1],z1[0],z1[2]});
      s1.insert(T{z1[1],z1[2],z1[0]});
      s1.insert(T{z1[2],z1[0],z1[1]});
      s1.insert(T{z1[2],z1[1],z1[0]});
      for(auto z2 : s1) ans.push_back(z2);
    }
    cout << ans.size() << endl;
    for(T z3 : ans){
      cout << z3[0] << ' ' << z3[1] << ' ' << z3[2] << endl;
    }
}

0