結果

問題 No.229 線分上を往復する3つの動点の一致
ユーザー btkbtk
提出日時 2015-06-20 01:15:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,626 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 91,296 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 04:33:33
合計ジャッジ時間 1,639 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>
#include<functional>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
LL L;
LL gcd(LL a, LL b){
	return (b == 0) ? a : gcd(b, a%b);
}
bool comp(P a, P b){
	LL c = a.second*b.second/gcd(a.second, b.second);
	a.first *= c / a.second;
	b.first *= c / b.second;
	return a.first < b.first;
}

P solve(LL x,LL y){
	LL u = (y/gcd(x, y))*(L/gcd(L,y));
	return make_pair(u / gcd(u, y), y / gcd(u, y));
}

int main(void){
	LL a, b, c;
	cin >> a >> b >> c;
	L = (a*b*c)/gcd(gcd(a,c),b);
	a = L / a;
	b = L / b;
	c = L / c;
	P res = make_pair(a*b*c, 1ll);
	{auto tmp = solve(a + b, a + c); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(a + c, a + b); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(c + b, a + c); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(a + b, b + c); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(a + c, c + b); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(c + b, a + b); if (comp(tmp, res))res = tmp; }

	{auto tmp = solve(abs(a - b), a + c); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(a - c), a + b); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(c - b), a + c); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(a - b), b + c); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(a - c), c + b); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(c - b), a + b); if (comp(tmp, res))res = tmp; }

	{auto tmp = solve( a + c, abs(a - b)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(a + b, abs(a - c)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve( a + c, abs(c - b)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve( b + c, abs(a - b)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve( c + b, abs(a - c)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve( a + b, abs(c - b)); if (comp(tmp, res))res = tmp; }

	{auto tmp = solve(abs(a - b), abs(a - c)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(a - c), abs(a - b)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(c - b), abs(a - c)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(a - b), abs(b - c)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(a - c), abs(c - b)); if (comp(tmp, res))res = tmp; }
	{auto tmp = solve(abs(c - b), abs(a - b)); if (comp(tmp, res))res = tmp; }
	cout << res.first << "/" << res.second << endl;
	return(0);
}
0