結果

問題 No.1936 Rational Approximation
ユーザー mencottonmencotton
提出日時 2022-05-13 22:03:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 900 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 76,376 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 07:18:09
合計ジャッジ時間 1,746 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <cassert>
#include <algorithm>

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef long double ld;

const ll INF = 1LL << 60;
const ll MOD = 998244353;
// using mint = modint998244353;
const string NEW_LINE = "\n";

inline void output_YesNo(bool x) { cout << (x ? "Yes" : "No") << endl; }
template<typename T>
inline void chmax(T &lhs, const T &rhs) { lhs = max(lhs, rhs); }
template<typename T>
inline void chmin(T &lhs, const T &rhs) { lhs = min(lhs, rhs); }

// #include <iomanip>
//
// void init_output() { cout << fixed << setprecision(15); }

int main() {
    ll p, q;
    cin >> p >> q;

    ll pl = p - 1, ql = q - 1, pr = p, qr = q - 1;
    {
        ll x = __gcd(pl, ql), y = __gcd(pr, qr);
        pl /= x, ql /= x, pr /= y, qr /= y;
    }

    cout << pl + ql + pr + qr << endl;
    return 0;
}
0