結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー firiexpfiriexp
提出日時 2019-11-21 11:57:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,343 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 97,236 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 21:18:48
合計ジャッジ時間 3,157 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 AC 2 ms
4,384 KB
testcase_40 AC 2 ms
4,384 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

pair<ll, ll> f(ll p, ll q, ll r, ll s){
    r *= q; p *= s;
    r /= __gcd(r, p);
    ll g = __gcd(r, q);
    r /= g, q /= g;
    g = __gcd(r, s);
    r /= g, s /= g;
    g = __gcd(p, q);
    p /= g, q /= g;
    g = __gcd(p, s);
    p /= g, s /= g;
    ll ans1 = r*p, ans2 = q*s;
    return {ans1, ans2};
}



template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << p.first << "/" << p.second;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    auto g = [&](pair<ll, ll> x, pair<ll, ll> y){
        ll g = __gcd(x.first, y.second);
        ll h = __gcd(x.second, y.first);
        return x.first/g*y.second < x.second/h*y.first;
    };
    vector<pair<ll, ll>> ans;

    ans.emplace_back(f(a*b, b-a, a*c, c-a));
    ans.emplace_back(f(a*b, b+a, a*c, c-a));
    ans.emplace_back(f(a*b, b-a, a*c, c+a));
    ans.emplace_back(f(a*b, b+a, a*c, c+a));
    cout << *min_element(ans.begin(),ans.end(), g) << "\n";
    return 0;
}
0