2019-07-21  2024-09-15    389 字  1 分钟

牛客-C881 J - Fraction Comparision

先判断整数部分,再判断小数部分

Code
 1/**
 2 *    author: Akvicor
 3 *    created: 2019-07-21 10-47-45
 4**/
 5
 6#include <bits/stdc++.h>
 7
 8using namespace std;
 9
10#ifdef DEBUG
11#define FAST_IO 17
12#else
13#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
14#define endl '\n'
15#endif
16
17#define rep(i, n) for(int i = 0; i < (n); ++i)
18#define reep(i, n) for(int i = 0; i <= (n); ++i)
19#define lop(i, a, n) for(int i = a; i < (n); ++i)
20#define loop(i, a, n) for(int i = a; i <= (n); ++i)
21#define prec(x) fixed << setprecision(x)
22#define ms(s, n) memset(s, n, sizeof(s))
23#define all(v) (v).begin(), (v).end()
24#define sz(x) ((int)(x).size())
25#define pb push_back
26#define mp make_pair
27#define fi first
28#define se second
29#define MOD(x) const int MOD = (int)x + 7
30#define MAXN(x) const int MAXN = (int)x + 7
31
32typedef long long LL;
33typedef unsigned long long ULL;
34typedef pair<int, int> PII;
35typedef vector<int> VI;
36typedef vector<PII> VII;
37
38namespace SOL{
39
40const double EPS = 1e-6;
41const double PI = acos(-1.0);
42const int INF = 0x3f3f3f3f;
43const LL LINF = 0x7f7f7f7f7f7f7f7f;
44
45/**  >------- Akvicor's Solution -------< **/
46
47MOD(1e9);
48MAXN(1e6);
49
50LL x, a, y, b;
51
52void solve(){
53    FAST_IO;
54    
55    while(cin >> x >> a >> y >> b){
56        if(x/a > y/b) cout << ">" << endl;
57	    else if(x/a < y/b) cout << "<" << endl;
58	    else if( (x%a)*b < (y%b)*a ) cout << "<" << endl;
59	    else if( (x%a)*b > (y%b)*a ) cout << ">" << endl;
60	    else cout << "=" << endl;
61    }
62    
63}
64
65/**  >----------------------------------< **/
66
67}
68
69int main(){
70
71#ifdef DEBUG
72    int DEBUGCNT = 0;
73    clock_t DEBUGstart, DEBUGfinish;
74    double DEBUGduration;
75    cout << ">------- Akvicor's Solution -------<" << endl;
76DEBUGLOOP:
77    DEBUGstart = clock();
78#endif
79
80    SOL::solve();
81
82#ifdef DEBUG
83    DEBUGfinish = clock();
84    DEBUGduration = (double)(DEBUGfinish - DEBUGstart)*1000 / CLOCKS_PER_SEC;
85    if(DEBUGduration > 0.07) cout << " --> Test: #" << DEBUGCNT << " time: " << fixed << setprecision(4) << DEBUGduration << " ms <--" << endl;
86    ++DEBUGCNT;
87    if(DEBUGCNT < 100) goto DEBUGLOOP;
88    cout << ">----------------------------------<" << endl;
89#endif
90
91    return 0;
92}

除另有声明外本博客文章均采用 知识共享 (Creative Commons) 署名 4.0 国际许可协议 进行许可转载请注明原作者与文章出处