結果

問題 No.816 Beautiful tuples
ユーザー totori_nyaatotori_nyaa
提出日時 2019-04-19 21:31:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 433 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 166,176 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-23 23:37:01
合計ジャッジ時間 2,170 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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