結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー 沙耶花
提出日時 2021-11-16 22:21:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 4,105 ms
コンパイル使用メモリ 251,300 KB
最終ジャッジ日時 2025-01-25 18:49:04
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:37: warning: ‘Y’ may be used uninitialized [-Wmaybe-uninitialized]
   50 |                                 if(A*Y<X*B){
      |                                    ~^~
main.cpp:17:21: note: ‘Y’ was declared here
   17 |         long long X,Y;
      |                     ^
main.cpp:50:41: warning: ‘X’ may be used uninitialized [-Wmaybe-uninitialized]
   50 |                                 if(A*Y<X*B){
      |                                        ~^~
main.cpp:17:19: note: ‘X’ was declared here
   17 |         long long X,Y;
      |                   ^

ソースコード

diff #

#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];
	}
	long long X,Y;
	rep(i,2){
		rep(j,2){
			long long xa = t[1]-t[0];
			if(i)xa = t[0] + t[1];
			long long xb = t[0] * t[1];
			long long ya = t[2]-t[0];
			if(j)ya = t[0] + t[2];
			long long yb = t[0] * t[2];
			
			long long g = gcd(xa,xb);
			xa /= g;
			xb /= g;
			
			g = gcd(ya,yb);
			ya /= g;
			yb /= g;
			
			swap(xa,xb);
			swap(ya,yb);
			
			long long B = lcm(xb,yb);
			xa *= B/xb;
			ya *= B/yb;
			long long A = lcm(xa,ya);
			
			g = gcd(A,B);
			A /= g;
			B /= g;
			if(i==0&&j==0){
				X = A,Y = B;
			}
			else{
				if(A*Y<X*B){
					X = A,Y = B;
				}
			}
		}
	}
	
	cout<<X<<'/'<<Y<<endl;
	
	return 0;
}
0