結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー nanasili
提出日時 2015-10-09 14:23:18
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 867 bytes
コンパイル時間 595 ms
コンパイル使用メモリ 70,928 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 02:22:51
合計ジャッジ時間 1,666 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>

using namespace std;

typedef long long ll;

/* gcdは最大公約数(greatest commond diviser) */
ll gcd(ll x, ll y) { 
  return y == 0 ? x : gcd(y, x % y); 
} 

/* lcmは最小公倍数(least commond multiple) */
ll lcm(ll x, ll y) { 
  return x / gcd(x, y) * y; 
} 

int main() {
  ll t1, t2, t3;
  cin >> t1 >> t2 >> t3;
  ll d = t1*t2*t3;
  ll n = 0;
  ll t[2] = {-1, 1};
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ll gcdt = gcd(t2*t3+t[i]*t1*t2, t1*t3+t[j]*t1*t2);
      if (gcdt > n) {
	n = gcdt;
      }
    }
  }

  ll div = gcd(d, n);
  std::cout << d/div << "/" << n/div << std::endl;
}
0