結果
問題 | No.1626 三角形の構築 |
ユーザー |
![]() |
提出日時 | 2021-07-25 01:30:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,496 ms / 2,000 ms |
コード長 | 1,359 bytes |
コンパイル時間 | 781 ms |
コンパイル使用メモリ | 97,800 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 11:59:37 |
合計ジャッジ時間 | 19,029 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 |
ソースコード
/* -*- 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; }