結果

問題 No.1626 三角形の構築
ユーザー tnakao0123tnakao0123
提出日時 2021-07-25 01:30:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,505 ms / 2,000 ms
コード長 1,359 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 97,952 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 16:13:14
合計ジャッジ時間 19,192 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 964 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 857 ms
6,940 KB
testcase_08 AC 1,070 ms
6,940 KB
testcase_09 AC 1,394 ms
6,940 KB
testcase_10 AC 839 ms
6,944 KB
testcase_11 AC 1,182 ms
6,944 KB
testcase_12 AC 242 ms
6,944 KB
testcase_13 AC 440 ms
6,940 KB
testcase_14 AC 797 ms
6,948 KB
testcase_15 AC 451 ms
6,940 KB
testcase_16 AC 923 ms
6,944 KB
testcase_17 AC 610 ms
6,940 KB
testcase_18 AC 651 ms
6,944 KB
testcase_19 AC 846 ms
6,944 KB
testcase_20 AC 1,015 ms
6,940 KB
testcase_21 AC 942 ms
6,940 KB
testcase_22 AC 1,505 ms
6,944 KB
testcase_23 AC 1,345 ms
6,944 KB
testcase_24 AC 898 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 193 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1626.cc:  No.1626 三角形の構築 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

struct Trpl {
  int a, b, c;
  Trpl() {}
  Trpl(int _a, int _b, int _c): a(_a), b(_b), c(_c) {}
  void print() { printf("%d %d %d\n", a, b, c); }
};

typedef vector<Trpl> vt;

/* global variables */

/* subroutines */

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    ll s, t;
    scanf("%lld%lld", &s, &t);

    ll ss = s * s, ht = t / 2;
    if ((t & 1) || ss % ht != 0) { puts("0"); continue; }

    ll xyz = ss / ht;
    vt ans;

    for (int x = 1; x < ht && (ll)x * x * x <= xyz; x++)
      if (xyz % x == 0) {
	ll yz = xyz / x;
	for (int y = x; y < ht && (ll)y * y <= yz; y++)
	  if (yz % y == 0) {
	    ll z = yz / y;
	    if (z < ht) {
	      int a = ht - z, b = ht - y, c = ht - x;
	      if ((ll)a + b + c == t)
		ans.push_back(Trpl(a, b, c));
	    }
	  }
      }

    printf("%lu\n", ans.size());
    for (auto p: ans) p.print();
  }
  return 0;
}
0