結果
| 問題 |
No.1626 三角形の構築
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-07-24 06:35:44 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,245 bytes |
| コンパイル時間 | 2,366 ms |
| コンパイル使用メモリ | 211,684 KB |
| 最終ジャッジ日時 | 2025-01-23 09:26:50 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 23 TLE * 3 |
ソースコード
#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;
}
umezo