QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#537438#5253. DenormalizationUESTC_DECAYALI#WA 0ms3804kbC++20993b2024-08-30 13:36:292024-08-30 13:36:29

Judging History

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

  • [2024-08-30 13:36:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-08-30 13:36:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using LD = long double;

const int N = 1e4+5;
int n, r[N];
LD A[N], rt[N];

int gcd(int a, int b){return 0==b ? a : gcd(b, a%b);}

bool check(){
    int d = 0;
    for (int i=1; i<=n; ++i) d += r[i]*r[i];
    LD dt = sqrtl(d);
    for (int i=1; i<=n; ++i) rt[i] = r[i]/dt;

    LD eps = 1e-6;
    for (int i=1; i<=n; ++i){
        if (abs(rt[i] - A[i]) >= eps) return false;
    }

    int g=r[1];
    for (int i=2; i<=n; ++i) g = gcd(g, r[i]);
    if (g>1) return false;
    return true;
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    int mn=1;
    for (int i=1; i<=n; ++i){
        cin >> A[i];
        if (A[i] < A[mn]) mn=A[i];
    }

    for (int i=1; i<=n; ++i){
        LD res = i / A[mn];
        for (int j=1; j<=n; ++j) r[j] = round(A[j]*res);
        if (check()) break;
    }

    for (int i=1; i<=n; ++i){
        cout << r[i] << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3804kb

input:

2
0.909840249060
0.414958698174

output:

-2147483648
-2147483648

result:

wrong answer Integer parameter [name=r_i] equals to -2147483648, violates the range [1, 10000]