結果

問題 No.1626 三角形の構築
ユーザー auauaauaua
提出日時 2021-07-23 23:05:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 2,181 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 174,596 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 16:01:39
合計ジャッジ時間 3,338 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 5 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 5 ms
5,376 KB
testcase_08 AC 5 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 5 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 4 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 80 ms
5,376 KB
testcase_25 AC 314 ms
5,376 KB
testcase_26 AC 18 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=3010;
const double PI=acos(-1.0);
typedef vector<vector<ll> > mat;
typedef vector<ll> vec;

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

signed main(){
    ll q;cin>>q;
    while(q--){
        ll s,t;
        cin>>s>>t;
        ll x=s*s*16LL;
        if(x%t!=0){
            cout<<0<<endl;
            continue;
        }
        x/=t;
        set<vector<ll> >st;
        for(ll i=1;i*i*i<=x;i++){
            if(x%i!=0)continue;
            if(t-i<=0||(t-i)%2!=0)continue;
            ll a=(t-i)/2;
            ll X=x;
            X/=(t-2LL*a);
            ll y=sqrt(t*t-2LL*(t-a)*t-X+(t-a)*(t-a));
            if(t*t-2LL*(t-a)*t-X+(t-a)*(t-a)==y*y){
                if((t-a+y)%2==0){
                    ll b=(t-a+y)/2LL;
                    ll c=t-a-b;
                    vector<ll>z(3);
                    z[0]=a,z[1]=b,z[2]=c;
                    sort(all(z));
                    if(z[0]>0&&z[1]+z[0]>z[2]){
                        st.insert(z);
                    }
                }
                if((t-a-y)%2==0){
                    ll b=(t-a-y)/2LL;
                    ll c=t-a-b;
                    vector<ll>z(3);
                    z[0]=a,z[1]=b,z[2]=c;
                    sort(all(z));
                    if(z[0]>0&&z[1]+z[0]>z[2]){
                        st.insert(z);
                    }
                }
            }
        }
        cout<<st.size()<<endl;
        for(auto e:st){
            rep(i,3){
                cout<<e[i]<<' ';
            }
            cout<<endl;
        }
    }
}
0