【題解】ZeroJudge a647: 投資專家

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=a647

#include <iostream>
using namespace std;

int main() {
    int n;
    double a, b;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a >> b;
        b -= a;
        b *= 100;
        b /= a;
        if (b > 0) b += 0.00001;
        if (b < 0) b -= 0.00001;
        if (b >= 10) printf(" %.2f%% dispose\n", b);
        else if (b <= -10) printf("%.2f%% dispose\n", b);
        else if (b >= 0) printf("  %.2f%% keep\n", b);
        else if (b >= -7) printf(" %.2f%% keep\n", b);
        else printf(" %.2f%% dispose\n", b);
    }
}
分享本文 Share with friends