結果

問題 No.816 Beautiful tuples
ユーザー tekihei2317tekihei2317
提出日時 2019-04-19 21:32:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,500 ms
コード長 676 bytes
コンパイル時間 4,423 ms
コンパイル使用メモリ 167,124 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 23:39:25
合計ジャッジ時間 2,592 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

bool check(int a,int b,int c)
{
    if((a+b)%c or (a+c)%b or (b+c)%a) return false;
    if(a==b or a==c or b==c) return false;
    else return true;
}

const int INF=1e18;

signed main()
{
    int A,B; cin>>A>>B;
    int ans=INF;
    for(int C=1;C*C<=(A+B);C++){
        if((A+B)%C==0){
            if(check(A,B,C)) ans=min(ans,C);
            if(check(A,B,(A+B)/C)) ans=min(ans,(A+B)/C);
        }
    }
    cout<<(ans==INF? -1:ans)<<endl;
}
0