結果

問題 No.750 Frac #1
ユーザー coco18000coco18000
提出日時 2018-11-09 21:25:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,055 bytes
コンパイル時間 1,380 ms
コンパイル使用メモリ 118,348 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-13 11:08:37
合計ジャッジ時間 3,829 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 RE -
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 RE -
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 RE -
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 1 ms
4,384 KB
testcase_24 RE -
testcase_25 AC 1 ms
4,380 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,384 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pair<double, double> P[20];

int n(int a, int b)
{
	if (a < b)
	{
		swap(a, b);
	}
	int c = a%b;
	if (c == 0)return b;
	return n(b, c);
}

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> P[i].first >> P[i].second;
	}

	sort(P, P + N, [](pair<double, double> a, pair<double, double> b) {return a.first / a.second > b.first / b.second; });
	REP(i, N)
	{
		int a = (int)P[i].first, b = (int)P[i].second;
		int t = n(abs(a), abs(b));
		cout << a / t << " " << b / t << endl;
	}
	return 0;
}
0