結果

問題 No.982 Add
ユーザー ferinferin
提出日時 2020-02-11 14:22:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,899 ms / 2,000 ms
コード長 1,051 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 204,288 KB
実行使用メモリ 265,756 KB
最終ジャッジ日時 2023-07-24 12:16:54
合計ジャッジ時間 35,122 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,343 ms
265,516 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1,612 ms
265,604 KB
testcase_03 AC 1,865 ms
265,200 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1,765 ms
265,316 KB
testcase_06 AC 1,609 ms
265,392 KB
testcase_07 AC 1,705 ms
265,380 KB
testcase_08 AC 1,667 ms
265,460 KB
testcase_09 AC 1,895 ms
265,428 KB
testcase_10 AC 1,878 ms
265,320 KB
testcase_11 AC 1,844 ms
265,272 KB
testcase_12 AC 1,552 ms
265,280 KB
testcase_13 AC 1,557 ms
265,272 KB
testcase_14 AC 1,220 ms
265,360 KB
testcase_15 AC 1,676 ms
265,352 KB
testcase_16 AC 1,736 ms
265,340 KB
testcase_17 AC 1,599 ms
265,336 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1,899 ms
265,756 KB
testcase_25 AC 1,875 ms
265,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll a, b;
    cin >> a >> b;

    if(gcd(a, b) != 1) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> v;
    REP(i, 5000) REP(j, 5000) if(a*i+b*j>0) v.push_back(a*i+b*j);
    sort(ALL(v));
    v.erase(unique(ALL(v)), v.end());
    // {
    //     vector<ll> d;
    //     REP(i, 400) d.push_back(v[i]);
    //     dump(d);
    // }

    ll sz = min((ll)v.size(), 20000LL);
    dump(v.back(), v.size());

    cout << v[sz-1] - sz << endl; 

    return 0;
}
0