結果

問題 No.1936 Rational Approximation
ユーザー baLoon8128baLoon8128
提出日時 2022-05-13 22:18:11
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 4,139 ms
使用メモリ 9,780 KB
最終ジャッジ日時 2023-02-21 15:05:13
合計ジャッジ時間 4,320 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
7,568 KB
testcase_01 AC 2 ms
7,588 KB
testcase_02 AC 2 ms
7,580 KB
testcase_03 AC 2 ms
7,572 KB
testcase_04 AC 1 ms
7,584 KB
testcase_05 AC 1 ms
9,680 KB
testcase_06 AC 1 ms
9,708 KB
testcase_07 AC 1 ms
7,608 KB
testcase_08 AC 1 ms
7,580 KB
testcase_09 AC 1 ms
9,780 KB
testcase_10 AC 1 ms
7,688 KB
testcase_11 AC 2 ms
7,576 KB
testcase_12 AC 2 ms
9,672 KB
testcase_13 AC 2 ms
9,692 KB
testcase_14 AC 1 ms
9,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repr(i, n) for (int i = (int)(n - 1); i >= 0; --i)

int main() {
    int p, q;
    cin >> p >> q;
    ll ret = 0;
    ll r, m;
    tie(r, m) = crt({0, q - 1}, {p, q});
    ret += r / p + (r + 1) / q;
    tie(r, m) = crt({0, 1}, {p, q});
    ret += r / p + (r + 1) / q;
    cout << ret << endl;
    return 0;
}
0