結果
| 問題 |
No.816 Beautiful tuples
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-06-10 20:52:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,500 ms |
| コード長 | 943 bytes |
| コンパイル時間 | 2,019 ms |
| コンパイル使用メモリ | 166,284 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 00:48:44 |
| 合計ジャッジ時間 | 1,887 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}
map<ll, ll> mp;
void divisor(ll n) {
for(ll i=1; i*i<=n; i++) {
if(n%i==0) {
mp[i]++;
mp[n/i]++;
}
}
}
int main(void) {
ll a, b;
cin >> a >> b;
divisor(a+b);
for(auto it=mp.begin(); it!=mp.end(); it++) {
ll c=it->ft;
ll ab=a+b, bc=b+c, ca=c+a;
if(c==a || c==b) continue;
if(ab%c==0 && bc%a==0 && ca%b==0) {
pt(c);
return 0;
}
}
pt(-1);
}