結果

問題 No.982 Add
ユーザー ugis_progugis_prog
提出日時 2020-02-11 13:57:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 465 bytes
コンパイル時間 1,506 ms
コンパイル使用メモリ 166,504 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 14:49:11
合計ジャッジ時間 2,362 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,676 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 WA -
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0