結果
問題 |
No.229 線分上を往復する3つの動点の一致
|
ユーザー |
![]() |
提出日時 | 2020-12-26 01:33:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 1,871 ms |
コンパイル使用メモリ | 196,120 KB |
最終ジャッジ日時 | 2025-01-17 07:27:01 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { vector<ll> T(3); for (int i = 0; i < 3; i++) { cin >> T[i]; } ll D = T[0] * T[1] * T[2]; pair<long, long> ans{D, 1ll}; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { ll N1 = T[1] * (T[2] + T[0] * (i ? 1 : -1)); ll N2 = T[0] * (T[2] + T[1] * (j ? 1 : -1)); pair<long, long> now{D, gcd(N1, N2)}; ll tmp = gcd(now.first, now.second); now.first /= tmp; now.second /= tmp; if (ans.first * now.second > ans.second * now.first) ans = now; } } cout << ans.first << "/" << ans.second << endl; }