結果

問題 No.982 Add
ユーザー mdstoymdstoy
提出日時 2020-02-11 14:36:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,395 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 172,656 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-08 15:06:14
合計ジャッジ時間 4,441 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 75 ms
6,548 KB
testcase_03 AC 78 ms
6,548 KB
testcase_04 WA -
testcase_05 AC 101 ms
8,320 KB
testcase_06 AC 98 ms
7,936 KB
testcase_07 AC 97 ms
7,552 KB
testcase_08 AC 71 ms
6,548 KB
testcase_09 AC 113 ms
11,136 KB
testcase_10 AC 119 ms
10,112 KB
testcase_11 AC 77 ms
6,548 KB
testcase_12 AC 59 ms
6,548 KB
testcase_13 AC 72 ms
6,548 KB
testcase_14 AC 115 ms
6,548 KB
testcase_15 AC 80 ms
6,548 KB
testcase_16 AC 108 ms
9,344 KB
testcase_17 AC 99 ms
8,064 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 128 ms
12,288 KB
testcase_25 AC 148 ms
12,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int a, b;
    cin >> a >> b;
    if (a % 2 == 0 && b % 2 == 0) {
        cout << -1 << endl;
        return;
    }
    set<int> s;
    REP(i, 1000) REP(j, 1000) {
        s.emplace(a * i + b * j);
    }
    int ans = 0;
    REP1(i, *(prev(s.end())) / 2) {
        if (s.count(i) == 0) ans++;
    }
    // cout << a * 999 + b * 999 << endl;
    // cout << *(prev(s.end())) << endl;
    cout << ans << endl;
}
0