結果

問題 No.750 Frac #1
ユーザー himagineer
提出日時 2019-08-09 22:46:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,530 bytes
コンパイル時間 1,762 ms
コンパイル使用メモリ 178,204 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-19 14:53:32
合計ジャッジ時間 2,907 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    int n;
    cin >> n;

    vector<tuple<double, int, int> > irreducible_fraction(n);
    for (int i = 0; i < n; i++)
    {
        double real_num, a, b;
        cin >> a >> b;
        real_num = a / b;

        irreducible_fraction[i] = {real_num, a, b};
    }
    sort(RALL(irreducible_fraction));

    for (int i = 0; i < n; i++)
    {
        cout << get<1>(irreducible_fraction[i]) << " " << get<2>(irreducible_fraction[i]) << endl;
    }

    return 0;
}
0