結果

問題 No.816 Beautiful tuples
コンテスト
ユーザー Cvadogsan
提出日時 2019-04-19 21:47:54
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 647 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,276 ms
コンパイル使用メモリ 207,628 KB
実行使用メモリ 16,208 KB
最終ジャッジ日時 2026-06-07 10:51:55
合計ジャッジ時間 4,820 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 1 RE * 3 TLE * 1 -- * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define ll long long
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
int main() {
  INIT;
  
  int a,b;
  cin >> a >> b;
  
  for (size_t c = b-a; c < 10^18; c+=b) {
    if((a+b) % c == 0 && (c+b) % a == 0 && (a+c) % b == 0){
      //cout << c << endl;
      printf("%d", c);
      exit(0);
    }
  }
  //cout << "-1" << endl;
  printf("-1");
  
  return 0;
}
0