結果
問題 | No.750 Frac #1 |
ユーザー |
![]() |
提出日時 | 2018-11-09 22:43:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,335 bytes |
コンパイル時間 | 686 ms |
コンパイル使用メモリ | 90,044 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 06:32:06 |
合計ジャッジ時間 | 1,676 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <iostream> #include <bitset> #include <fstream> #include <string> #include <cstring> #include <cmath> #include <cstdlib> #include <ctime> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <functional> #include <cctype> #include <list> #include <limits> //#include <boost/multiprecision/cpp_int.hpp> const double EPS = (1e-10); using namespace std; using Int = long long; //using namespace boost::multiprecision; const Int MOD = 1000000007; Int mod_pow(Int x, Int n) { Int res = 1; while(n > 0) { if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき) x = (x * x) % MOD; n >>= 1; //右シフト(n = n >> 1) } return res; } vector<pair<Int, Int>> a; int main(){ cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++){ pair<Int, Int> tmp; cin >> tmp.first >> tmp.second; a.push_back(tmp); } for (int i = 0; i < n; i++){ for (int j = 0; j < n-1-i; j++){ if (a[j].second * a[j+1].first < a[j+1].second * a[j].first){ swap(a[j], a[j+1]); } } } for (int i = n-1; i >= 0; i--){ cout << a[i].first <<" "<< a[i].second << endl; } }