結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー chocoruskchocorusk
提出日時 2019-08-05 23:27:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,054 bytes
コンパイル時間 1,364 ms
コンパイル使用メモリ 101,132 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-25 17:35:42
合計ジャッジ時間 3,612 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b, a%b);
}
int main()
{
    ll t1, t2, t3;
    cin>>t1>>t2>>t3;
    vector<P> v;
    for(int p=-1; p<=1; p+=2){
        for(int q=-1; q<=1; q+=2){
            ll x=t1*(t3-q*t2), y=t3*(t2-p*t1);
            ll g=gcd(x, y);
            ll a=t1*t2*y/g, b=t2-p*t1;
            ll h=gcd(a, b);
            v.push_back({a/h, b/h});
        }
    }
    P ans=*min_element(v.begin(), v.end(), [&](P x, P y){ return x.first*y.second<y.first*x.second;});
    printf("%lld/%lld\n", ans.first, ans.second);
    return 0;
}
0