結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー pekempeypekempey
提出日時 2015-06-19 23:51:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,555 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 148,372 KB
実行使用メモリ 5,256 KB
最終ジャッジ日時 2023-09-21 10:23:09
合計ジャッジ時間 3,124 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrep2(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

ll lcm(ll x, ll y) {
    return x / __gcd(x, y) * y;
}

int main() {
    ll T[3];
    rep (i, 3) cin >> T[i];

    ll U[6];

    sort(T, T + 3);

    U[0] = T[0] + T[1];
    U[1] = T[1] + T[2];
    U[2] = T[2] + T[0];
    U[3] = T[1] - T[0];
    U[4] = T[2] - T[1];
    U[5] = T[2] - T[0];

    if (3 * T[0] >= T[1]) U[3] = U[0];
    if (3 * T[2] >= T[1]) U[4] = U[1];
    if (3 * T[2] >= T[0]) U[5] = U[2];

    ll m = U[0];

    rep (i, 6) m = lcm(m, U[i]);

    ll S[6];
    S[0] = m * T[0] * T[1] / (T[0] + T[1]);
    S[1] = m * T[1] * T[2] / (T[1] + T[2]);
    S[2] = m * T[2] * T[0] / (T[2] + T[0]);
    S[3] = m * T[0] * T[1] / (T[1] - T[0]);
    S[4] = m * T[1] * T[2] / (T[2] - T[1]);
    S[5] = m * T[2] * T[0] / (T[2] - T[0]);

    ll n[8];
    n[0] = lcm(S[0], lcm(S[1], S[2]));
    n[1] = lcm(S[3], lcm(S[1], S[2]));
    n[2] = lcm(S[0], lcm(S[4], S[2]));
    n[3] = lcm(S[3], lcm(S[4], S[2]));
    n[4] = lcm(S[0], lcm(S[1], S[5]));
    n[5] = lcm(S[3], lcm(S[1], S[5]));
    n[6] = lcm(S[0], lcm(S[4], S[5]));
    n[7] = lcm(S[3], lcm(S[4], S[5]));

    ll x = *min_element(n, n + 8);

    ll g = __gcd(m, x);

    m /= g;
    x /= g;

    cout << x << "/" << m << endl;
}
0