結果
| 問題 | No.229 線分上を往復する3つの動点の一致 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2015-09-15 17:15:22 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,395 bytes | 
| コンパイル時間 | 1,112 ms | 
| コンパイル使用メモリ | 91,120 KB | 
| 実行使用メモリ | 10,144 KB | 
| 最終ジャッジ日時 | 2024-07-19 06:37:03 | 
| 合計ジャッジ時間 | 7,515 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 4 TLE * 1 -- * 38 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
int inputValue(){
    int a;
    cin >> a;
    return a;
};
void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};
void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}
// a < b
ll gcd(ll a, ll b){
    if (a > b) {
        swap(a, b);
    }
    
    if (b % a == 0) {
        return a;
    }
    else{
        ll g = b % a;
        return gcd(g, a);
    }
}
// a < b
ll lcm(ll a, ll b){
    
    return (ll)a * (ll)b / (ll)gcd(a, b);
    
}
// first:分子 second:分母
// x = 6 / 5, y = 4 / 3: return: 12 / 1
pair<ll, ll> smallest(pair<ll, ll> x, pair<ll, ll> y){
    
    pair<ll, ll> ret;
    
    ret.second = lcm(x.second, y.second);
    ret.first = lcm(x.first * (ret.second / x.second), y.first * (ret.second / y.second));
    
    ll g = gcd(ret.first, ret.second);
    
    ret.first /= g;
    ret.second /= g;
    
    return ret;
}
int main(int argc, const char * argv[]) {
    
    // source code
    vector<ll> T(3);
    rep(i, 3){
        T[i] = (ll)inputValue();
    }
    
    sort(T.begin(), T.end());
    
    vector<pair<ll, ll> > M(4);
    
    M[0] = smallest(make_pair(T[0] * T[1], T[0] + T[1]), make_pair(T[0] * T[2], T[0] + T[2]));
    
    M[1] = smallest(make_pair(T[0] * T[1], T[0] + T[1]), make_pair(T[0] * T[2], T[2] - T[0]));
    
    M[2] = smallest(make_pair(T[0] * T[1], T[1] - T[0]), make_pair(T[0] * T[2], T[0] + T[2]));
    
    M[3] = smallest(make_pair(T[0] * T[1], T[1] - T[0]), make_pair(T[0] * T[2], T[2] - T[0]));
    
    vector<double> D(4);
    int ii = 0;
    double min = (double)M[0].first / (double)M[0].second;
    
    rep(i, 4){
        D[i] = (double)M[i].first / (double)M[i].second;
        if (min > D[i]) {
            min = D[i];
            ii = i;
        }
    }
    
    cout << M[ii].first << "/" << M[ii].second << endl;
    
    return 0;
}
            
            
            
        