結果

問題 No.982 Add
ユーザー konchanksu
提出日時 2020-03-08 22:06:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 448 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 63,360 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 19:40:19
合計ジャッジ時間 1,726 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int coprime(int a, int b){
    if(a > b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    for(int i = 2; i <= a; i++){
        if(a % i == 0 && b % i == 0) return false;
    }
    return true;
}

int main(void){
    int a, b;

    cin >> a >> b;
    if(coprime(a, b) == false){
        cout << -1 << endl;
        return 0;
    }

    cout << (a - 1) * (b - 1) / 2 << endl;

    return 0;
}
0