結果
| 問題 |
No.229 線分上を往復する3つの動点の一致
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2019-08-05 23:27:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,054 bytes |
| コンパイル時間 | 774 ms |
| コンパイル使用メモリ | 102,816 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 13:50:05 |
| 合計ジャッジ時間 | 2,057 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
ソースコード
#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;
}
chocorusk