QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#94496#5253. Denormalizationmaomao90#WA 3ms3696kbC++172.0kb2023-04-06 14:14:182023-04-06 14:14:29

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-06 14:14:29]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3696kb
  • [2023-04-06 14:14:18]
  • 提交

answer


// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 10000;

int n;
ld x[MAXN];
int ans[MAXN];

int main() {
#ifndef DEBUG
    ios::sync_with_stdio(0), cin.tie(0);
#endif
    cin >> n;
    ld mnx = INF;
    REP (i, 0, n) {
        cin >> x[i];
        mnto(mnx, x[i]);
    }
    while (mnx * 10 < 1) {
        mnx *= 10;
        REP (i, 0, n) {
            x[i] *= 10;
        }
    }
    ld mn = INF;
    int ak = -1;
    REP (k, 1, MAXN * 10) {
        ld error = 0;
        bool pos = 1;
        REP (i, 0, n) {
            ld tx = x[i] * k;
            int ix = round(tx);
            if (ix == 0 || ix > MAXN) {
                pos = 0;
                break;
            }
            error += abs(ix - tx);
        }
        if (!pos) {
            continue;
        }
        if (mnto(mn, error)) {
            ak = k;
        }
    }
    REP (i, 0, n) {
        ans[i] = round(x[i] * ak);
    }
    int g = 0;
    REP (i, 0, n) {
        g = __gcd(g, ans[i]);
    }
    REP (i, 0, n) {
        ans[i] /= g;
    }
    REP (i, 0, n) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 3696kb

input:

2
0.909840249060
0.414958698174

output:

296
135

result:

wrong answer incorrect solution