結果

問題 No.1626 三角形の構築
ユーザー umezoumezo
提出日時 2021-07-24 06:19:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,283 bytes
コンパイル時間 2,529 ms
コンパイル使用メモリ 211,900 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-20 16:10:18
合計ジャッジ時間 6,003 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
10,624 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0