結果

問題 No.816 Beautiful tuples
ユーザー totori_nyaa
提出日時 2019-04-19 21:31:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 433 bytes
コンパイル時間 1,625 ms
コンパイル使用メモリ 167,384 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 16:46:09
合計ジャッジ時間 2,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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