結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー tnakao0123tnakao0123
提出日時 2016-04-12 15:41:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,401 bytes
コンパイル時間 612 ms
コンパイル使用メモリ 86,400 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 00:41:13
合計ジャッジ時間 1,827 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 229.cc: No.229 線分上を往復する3つの動点の一致 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;
typedef pair<ll,ll> pll;

/* global variables */

/* subroutines */

pll calc_t(int t1, int t2, int t3, int s0, int s1) {
  int num0 = t3 + s0 * t1, den0 = t1 * t3;
  int g0 = __gcd(num0, den0);
  num0 /= g0, den0 /= g0;

  int num1 = t3 + s1 * t2, den1 = t2 * t3;
  int g1 = __gcd(num1, den1);
  num1 /= g1, den1 /= g1;

  int gd = __gcd(den0, den1);
  ll den = (ll)den0 * den1 / gd;
  ll num = __gcd((ll)num0 * den1 / gd, (ll)num1 * den0 / gd);

  return pll(den, num);
}

/* main */

int main() {
  int t1, t2, t3;
  cin >> t1 >> t2 >> t3;

  pll a0 = calc_t(t1, t2, t3, -1, -1);
  pll a1 = calc_t(t1, t2, t3,  1, -1);
  pll a2 = calc_t(t1, t2, t3, -1,  1);
  pll a3 = calc_t(t1, t2, t3,  1,  1);

  ll maxd = a0.second;
  if (maxd < a1.second) maxd = a1.second;
  if (maxd < a2.second) maxd = a2.second;
  if (maxd < a3.second) maxd = a3.second;

  printf("%lld/%lld\n", a0.first, maxd);
  return 0;
}
0