結果

問題 No.2358 xy+yz+zx=N
ユーザー YwestbuilderkYwestbuilderk
提出日時 2024-03-16 17:02:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 213,296 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-16 17:02:53
合計ジャッジ時間 4,623 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 144 ms
6,676 KB
testcase_09 AC 148 ms
6,676 KB
testcase_10 AC 116 ms
6,676 KB
testcase_11 AC 116 ms
6,676 KB
testcase_12 AC 80 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

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