結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
tekihei2317
|
| 提出日時 | 2019-04-19 21:31:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 676 bytes |
| コンパイル時間 | 1,512 ms |
| コンパイル使用メモリ | 168,000 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-22 16:46:03 |
| 合計ジャッジ時間 | 2,145 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 8 |
ソースコード
#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;
}
tekihei2317