結果
| 問題 |
No.229 線分上を往復する3つの動点の一致
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-04-12 15:41:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,401 bytes |
| コンパイル時間 | 595 ms |
| コンパイル使用メモリ | 84,700 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-04 07:16:55 |
| 合計ジャッジ時間 | 2,094 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
/* -*- 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;
}
tnakao0123