結果
| 問題 | No.1626 三角形の構築 | 
| コンテスト | |
| ユーザー |  umezo | 
| 提出日時 | 2021-07-24 06:19:48 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,283 bytes | 
| コンパイル時間 | 2,453 ms | 
| コンパイル使用メモリ | 210,620 KB | 
| 最終ジャッジ日時 | 2025-01-23 09:25:20 | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 5 TLE * 21 | 
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
vector<ll> divisor(ll x){
  set<ll> s;
  for(ll i=1;i*i<=x;i++){
    if(x%i==0){
      s.insert(i);
      s.insert(x/i);
    }
  }
  vector<ll> res;
  for(auto y:s) res.push_back(y);
  return res;
}
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int t;
  cin>>t;
  while(t--){
    ll S,T;
    cin>>S>>T;
    
    if(16*S*S%T!=0){
      cout<<0<<endl;
      continue;
    }
    
    ll U=16*S*S/T;
    vector<ll> A=divisor(U);
    sort(ALL(A));
    
    int n=A.size();
    set<pair<ll,pair<ll,ll>>> s;
    rep(i,n){
      if((T-A[i])%2==1) continue;
      for(int j=i;j<n;j++){
        if((T-A[j])%2==1) continue;
        for(int k=j;k<n;k++){
          if((T-A[k])%2==1) continue;
          if(log(A[i])+log(A[j])+log(A[k])>log(U)+1e5) continue;
          if(A[i]*A[j]*A[k]!=U) continue;
          if(A[i]+A[j]+A[k]!=T) continue;
          if(A[j]+A[k]>=T+A[i]) continue;        
          s.insert({(T-A[i])/2,{(T-A[j])/2,(T-A[k])/2}});
        }
      }
    }
    
    cout<<s.size()<<endl;
    for(auto t:s){
      cout<<t.first<<" "<<t.second.first<<" "<<t.second.second<<endl;
    }
  }
  return 0;
}
            
            
            
        