結果

問題 No.816 Beautiful tuples
ユーザー yosakayosaka
提出日時 2019-04-21 03:03:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 575 bytes
コンパイル時間 1,858 ms
コンパイル使用メモリ 163,004 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 22:30:24
合計ジャッジ時間 10,940 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 44 ms
6,940 KB
testcase_03 AC 93 ms
6,940 KB
testcase_04 WA -
testcase_05 TLE -
testcase_06 WA -
testcase_07 AC 226 ms
6,944 KB
testcase_08 AC 112 ms
6,944 KB
testcase_09 AC 126 ms
6,940 KB
testcase_10 AC 1,002 ms
6,940 KB
testcase_11 AC 1,005 ms
6,944 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A, B;
    int i;
    cin >> A >> B;
    for (i=max(A, B); i > 0; i--)
    {
        if (A % i == 0 && B % i == 0)
        {
            A /= i;
            B /= i;
            break;
        }
    }
    //cout << A << " " << B << " " << i << endl;
    
    if (min(A, B) == max(A, B) - 1)
    {
        cout << (min(A, B) + 2) * i << endl;
    }
    else if (min(A, B) == max(A, B) - 2)
    {
        cout << (min(A, B) + 1) * i << endl;
    }
    else 
    {
        cout << -1 << endl;
    }
    return 0;
}
0