結果

問題 No.816 Beautiful tuples
ユーザー bamboo_circlebamboo_circle
提出日時 2019-04-19 21:24:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 1,842 ms
コンパイル使用メモリ 159,456 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2023-10-23 23:02:09
合計ジャッジ時間 5,333 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	ll a,b;
    cin >> a >> b;
    ll s = a + b;
    ll ans = -1;
    for(ll i = 1; i <= s; i++){
        if(s % i != 0) continue;

        if((i+a)%b == 0 && (i+b)%a == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}
0