結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
10,752 KB
testcase_01 AC 648 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 628 ms
5,376 KB
testcase_08 AC 790 ms
5,376 KB
testcase_09 AC 1,008 ms
5,376 KB
testcase_10 AC 585 ms
5,376 KB
testcase_11 AC 945 ms
5,376 KB
testcase_12 AC 204 ms
5,376 KB
testcase_13 AC 289 ms
5,376 KB
testcase_14 AC 639 ms
5,376 KB
testcase_15 AC 404 ms
5,376 KB
testcase_16 AC 621 ms
5,376 KB
testcase_17 AC 640 ms
5,376 KB
testcase_18 AC 558 ms
5,376 KB
testcase_19 AC 689 ms
5,376 KB
testcase_20 AC 841 ms
5,376 KB
testcase_21 AC 701 ms
5,376 KB
testcase_22 AC 1,174 ms
5,376 KB
testcase_23 AC 923 ms
5,376 KB
testcase_24 TLE -
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;
        if((U/A[i])%A[j]!=0) continue;
        ll k=U/A[i]/A[j];
        if((T-k)%2==1) continue;
        if(A[i]+A[j]+k!=T) continue;
        vector<ll> B={A[i],A[j],k};
        sort(ALL(B));
        if(B[1]+B[2]>=T+B[0]) continue;        
        s.insert({(T-B[0])/2,{(T-B[1])/2,(T-B[2])/2}});
      }
    }
    
    cout<<s.size()<<endl;
    for(auto t:s){
      cout<<t.first<<" "<<t.second.first<<" "<<t.second.second<<endl;
    }
  }

  return 0;
}
0