結果

問題 No.1626 三角形の構築
ユーザー coder_neetcoder_neet
提出日時 2021-08-05 01:22:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,181 ms / 2,000 ms
コード長 3,917 bytes
コンパイル時間 1,685 ms
コンパイル使用メモリ 177,856 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 16:14:37
合計ジャッジ時間 9,679 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 296 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 368 ms
5,376 KB
testcase_08 AC 355 ms
5,376 KB
testcase_09 AC 406 ms
5,376 KB
testcase_10 AC 269 ms
5,376 KB
testcase_11 AC 399 ms
5,376 KB
testcase_12 AC 91 ms
5,376 KB
testcase_13 AC 170 ms
5,376 KB
testcase_14 AC 268 ms
5,376 KB
testcase_15 AC 196 ms
5,376 KB
testcase_16 AC 261 ms
5,376 KB
testcase_17 AC 296 ms
5,376 KB
testcase_18 AC 349 ms
5,376 KB
testcase_19 AC 315 ms
5,376 KB
testcase_20 AC 354 ms
5,376 KB
testcase_21 AC 317 ms
5,376 KB
testcase_22 AC 477 ms
5,376 KB
testcase_23 AC 523 ms
5,376 KB
testcase_24 AC 1,181 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 115 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
#define int long long
#define rep(i,a) for (int i = 0; i < (a); i++ )
#define Rep(i,start,a) for (int i = start; i < (a); i++ )
#define ALL(vec) (vec).begin(), (vec).end()
#define Sort(vec) sort((vec).begin(), (vec).end()) // 小さい順
#define SORT(vec) sort((vec).begin(), (vec).end(), [](auto a, auto b){return a>b;}) // 大きい順
#define SORTll(vec) sort((vec).begin(), (vec).end(), [](long long a, long long b){return a>b;}) // 大きい順
#define debug(x) cerr << #x << " = " << (x) << endl
#define Bit(s,k) (s>>k)&1
#define VI vector<int>
#define VLL vector<long long>
#define PII pair<int,int>
#define VPII vector<PII>
#define VB vector<bool>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define Graph vector<vector<int>>
#define PB emplace_back
#define USI unordered_set<int>
#define Maze vector<string>
#define Pqueue priority_queue
#define MP make_pair
#define WeightedGraph vector<vector<pair<int,ll>>> // parent, (to, cost)

#define vecdebug(vec) {cerr << #vec << " = [" ; for(auto x : (vec)){cerr << (x) << ", ";} cerr << "]" << endl; }
#define vdebug(vec,i) cerr << #vec << "[" << (i) << "] = " << (vec)[(i)] << endl
#define vvdebug(vec,i,j) cerr << #vec << "[" << (i) << "][" << (j) << "] = " << (vec)[(i)][(j)] << endl
#define vvvdebug(vec,i,j,k) cerr << #vec << "[" << (i) << "][" << (j) << "][" << (k) <<"] = " << (vec)[(i)][(j)][(k)] << endl
#define pdebug(p) cerr << #p << " = [" << (p).first << ", " << (p).second << "]" << endl

typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const int MOD = 1000000007;
const ll INFLL = (1LL << 60) -1;
const int INF = (1 << 30) -1;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const long double pi = 2*asin(1);

using namespace std;
//using namespace atcoder;

//using mint = modint1000000007;
//using mint = modint998244353;
//using mint = modint998244353;
//using mint = static_modint<7>;


template<typename T>
inline void chmin(T &x, T y){if(x>y) x=y;}

template<typename T>
inline void chmax(T &x, T y){if(x<y) x=y;}

inline int tonum(char X){
  if(X >= 'A' && X <= 'Z') return 26 + (int)(X-'A');
  return (int)(X - 'a');
}

inline int ctoi(char x){return (int)(x-'0');}

template<typename T>
T Max(T x, T y){if(x>y) return x; return y;}

template<typename T>
T Min(T x, T y){if(x<y) return x; return y;}

inline int tochar(int n){return (char)('a' + n);}

template<typename T>
inline T ABS(T n){if(n<0) return -n; return n;}

ll GCD(ll a, ll b){if(a%b==0) return b; return GCD(b,a%b);}

ll LCM(ll a, ll b){return a / GCD(a,b) *b;}





vector<int> divisors(int n){
  vector<int> ret;
  Rep(i,1,n+1){
    if(i*i>n) break;
    if(i*i==n){
      ret.PB(i);
      break;
    }
    if(n%i==0){
      ret.PB(i);
      ret.PB(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

void solve(){
  int S,T; cin >> S >> T;

  if((4 * S * S) % T != 0){
    cout << 0 << endl;
    return;
  }



  //debug("!");

  set<PII> st;

  int val = 16 * S * S / T;

  if(val / (T * T) > 27 * T * T){
    cout << 0 << endl;
    return;
  }
  debug(val / (T*T) - T*T);

  auto div = divisors(16 * S * S / T);

  //vecdebug(div);
  
  int sz = div.size();



  rep(i,sz){
    if(3 * div[i] > T) break;
    Rep(j,i,sz){
      int x = div[i];
      int y = div[j];
      if(x + 2 * y > T) break;
      if((x + y) & 1) continue;
      if((T - x) & 1) continue;
      if(val / x ==  y * (T - x - y)) st.insert(MP(x,y));
    }
  }

  cout << st.size() << endl;

  for(auto p : st){
    int x = p.first;
    int y = p.second;
    int z = T - x - y;

    int a = (x + y) / 2;
    int b = (y + z) / 2;
    int c = (z + x) / 2;

    cout << a << " " << b << " " << c << endl;
  }


}

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);


  int Query; cin >> Query; rep(_,Query)
  solve();
}
0