結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-08-22 16:38:26 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 368 bytes | 
| コンパイル時間 | 2,128 ms | 
| コンパイル使用メモリ | 191,788 KB | 
| 最終ジャッジ日時 | 2025-01-07 14:37:45 | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 7 WA * 8 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int a,b;
    cin>>a>>b;
    for (int i=1;i*i<=a+b;i++)
        if ((a+b)%i==0&&(a+i)%b==0&&(b+i)%a==0) {
            cout<<i<<endl;
            return 0;
        }
    if ((a+b)%a==0&&(a+b)%b==0) {
        cout<<a+b<<endl;
        return 0;
    }
    cout<<-1<<endl;
    return 0;
}
            
            
            
        