結果

問題 No.816 Beautiful tuples
ユーザー ttttan
提出日時 2019-04-19 21:56:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 325 bytes
コンパイル時間 1,190 ms
コンパイル使用メモリ 158,864 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-22 19:01:56
合計ジャッジ時間 1,826 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b;cin>>a>>b;
    if(a>b)swap(a,b);
    ll u=b-a;
  if((u+a)%b==0&&(u+b)%a==0&&(a+b)%u==0){
    cout<<u<<endl;
    return 0;
  }
  u=2*b-a;
  if((u+a)%b==0&&(u+b)%a==0&&(a+b)%u==0){
    cout<<u<<endl;
    return 0;
  }
  cout<<-1<<endl;
}
0