結果

問題 No.816 Beautiful tuples
ユーザー kakulin_realkakulin_real
提出日時 2019-04-22 09:49:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 162,184 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 23:33:09
合計ジャッジ時間 2,017 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
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 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll a,b;
ll c;
ll ans = INF;

int main(){
  cin >> a >> b;
  for(c = 1;c*c <= a+b;c++){
    if((a+b)%c == 0){
      if((a+c)%b == 0 && (b+c)%a == 0) ans = min(ans,c);
      ll c_ = (a+b)/c;
      if((a+c_)%b == 0 && (b+c_)%a == 0) ans = min(ans,c_);
    }
  }
  cout << (ans == INF ? -1 : ans) << endl;
}
0