結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2020-03-12 17:01:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 647 bytes |
コンパイル時間 | 1,525 ms |
コンパイル使用メモリ | 166,480 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 19:40:18 |
合計ジャッジ時間 | 2,593 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }