結果
| 問題 | 
                            No.982 Add
                             | 
                    
| コンテスト | |
| ユーザー | 
                             msm1993
                         | 
                    
| 提出日時 | 2020-03-31 18:09:21 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 647 bytes | 
| コンパイル時間 | 1,931 ms | 
| コンパイル使用メモリ | 165,392 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-24 22:09:36 | 
| 合計ジャッジ時間 | 2,494 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 23 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
#define LINF (1LL << 60)
typedef long long i64;
typedef pair<i64,i64> P;
inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int a,b;
void solve(){
	cin >> a >> b;
	
	if(__gcd(a,b) != 1){
		cout << -1 << endl;
		return;
	}
	cout << (a-1)*(b-1)/2 << endl;
}
int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}
            
            
            
        
            
msm1993