結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2020-02-11 13:57:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 465 bytes |
コンパイル時間 | 1,455 ms |
コンパイル使用メモリ | 167,560 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 07:27:48 |
合計ジャッジ時間 | 2,262 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 6 |
ソースコード
#include<bits/stdc++.h> using namespace std; using i64 = int_fast64_t; #define rep(i, N) for(int (i) = 0; (i) < (N); (i)++) #define all(v) (v).begin(), (v).end() #define eb emplace_back int gcd(int n,int m){return m?gcd(m,n%m):n;} int lcm(int n,int m){return n*m/gcd(n,m);} int main(){ int A,B; cin >> A >> B; int ans = lcm(A, B); ans -= (ans/A + ans/B) - (ans/(A*B)); ans /= 2; if((A&1) == (B&1)) ans = -1; cout << ans << endl; }