結果
| 問題 |
No.229 線分上を往復する3つの動点の一致
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-11-16 22:32:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,071 bytes |
| コンパイル時間 | 3,946 ms |
| コンパイル使用メモリ | 252,056 KB |
| 最終ジャッジ日時 | 2025-01-25 18:49:33 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:52:37: warning: ‘Y’ may be used uninitialized [-Wmaybe-uninitialized]
52 | if(A*Y<X*B){
| ~^~
main.cpp:17:20: note: ‘Y’ was declared here
17 | __int128 X,Y;
| ^
main.cpp:52:41: warning: ‘X’ may be used uninitialized [-Wmaybe-uninitialized]
52 | if(A*Y<X*B){
| ~^~
main.cpp:17:18: note: ‘X’ was declared here
17 | __int128 X,Y;
| ^
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
int main(){
vector<long long> t(3);
rep(i,3){
cin>>t[i];
}
__int128 X,Y;
rep(i,2){
rep(j,2){
__int128 xa = t[1]-t[0];
if(i)xa = t[0] + t[1];
__int128 xb = t[0] * t[1];
__int128 ya = t[2]-t[0];
if(j)ya = t[0] + t[2];
__int128 yb = t[0] * t[2];
__int128 g = gcd((long long)xa,(long long)xb);
xa /= g;
xb /= g;
g = gcd((long long)ya,(long long)yb);
ya /= g;
yb /= g;
swap(xa,xb);
swap(ya,yb);
__int128 B = lcm((long long)xb,(long long)yb);
xa *= B/xb;
ya *= B/yb;
__int128 A = xa/gcd((long long)xa,(long long)ya);
A *= ya;//lcm(xa,ya);
g = gcd((long long)A,(long long)B);
A /= g;
B /= g;
if(i==0&&j==0){
X = A,Y = B;
}
else{
if(A*Y<X*B){
X = A,Y = B;
}
}
}
}
long long aa = X,bb = Y;
cout<<aa<<'/'<<bb<<endl;
return 0;
}
沙耶花