結果

問題 No.816 Beautiful tuples
ユーザー irohasu_takaokairohasu_takaoka
提出日時 2019-05-03 20:40:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 987 bytes
コンパイル時間 1,061 ms
コンパイル使用メモリ 80,352 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-30 05:51:57
合計ジャッジ時間 5,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}

void Yn(bool f)
{
  cout << (f ? "Yes" : "No") << endl;
}

void yn(bool f)
{
  cout << (f ? "yes" : "no") << endl;
}

void YN(bool f)
{
  cout << (f ? "YES" : "NO") << endl;
}

ll a, b;

ll solve(){
  if(a == b)
    return -1;

  for (ll i = 1; i <= a + b; i++)
  {
    if (a == i || b == i)
      continue;

    if ((a + b) % i == 0 && (a+i)%b == 0 && (b+i)%a == 0)
      return i;
  }

  return -1;
}

int main()
{
  cin >> a>>b;
  cout << solve() << endl;
  
  return 0;
}
0