結果

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

テストケース

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

ソースコード

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);
}

typedef long double LD;
bool comp(P a, P b){

	return a.first/(LD)a.second < b.first/(LD)b.second;
}

P solve(LL x,LL y){
	LL u = (y/gcd(x, y))*(L/gcd(L,y));
	y /= 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);

	P res = make_pair(L, 1ll);
	a = L / a;
	b = L / b;
	c = L / c;
	{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