QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#135848#5253. DenormalizationLeticiaFCSWA 1755ms3720kbC++201.7kb2023-08-06 08:54:122023-08-06 08:54:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-06 08:54:15]
  • 评测
  • 测评结果:WA
  • 用时:1755ms
  • 内存:3720kb
  • [2023-08-06 08:54:12]
  • 提交

answer

#include"bits/stdc++.h"

using lint = int64_t;

constexpr int MOD = int(1e9) + 7;
constexpr int INF = 0x63636363;
constexpr int NINF = 0xcfcfcfcf;
constexpr lint LINF = 0x6363636363636363;

using namespace std;

using ld = long double;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int n; cin>>n;
    vector<ld> v(n);
    for(int i = 0; i<n; i++){
        cin>>v[i];
    }    
    ld mini = v[0], maxi = v[0];
    for(int i = 0; i<n; i++){
        mini = min(mini, v[i]);
        maxi = max(maxi, v[i]);
    }

    sort(v.begin(), v.end());
    tuple<ld, int, int> candidate = {1e8,1,1};
    ld frac = mini / maxi;
    for(int p=1; p<=10000; p++)
        for(int q = p; q<=10000; q++){
            if(__gcd(p, q) == 1){
                candidate = min(candidate, tuple<ld, int, int>(abs(frac - ld(p)/q), p, q));
            }
        }
    int p = get<1>(candidate);
    //1 6
    for(int k = 1; p * k <= 10; k++){
        int x = p * k;
        /*
            v[i] = x / d
            d = x / v[i]
        */
        ld d = ld(x) / mini;
        bool ok = true;
        vector<int> ans(n);
        ld real_d = 0;
        for(int i =0; i<n && ok; i++){
            /*
            v[i] = ans[i] / d
            ans[i] = v[i] * d
            */
            ans[i] = round(v[i] * d);
            if(ans[i] > 10000) ok = false;
            real_d += ans[i] * ans[i];
        }
        real_d = sqrt(real_d);
        for(int i =0; i<n && ok; i++){
            if(abs(v[i] - ld(ans[i]) / real_d) > 1e-6)
                ok = false;
        }

        if(ok){
            for(int x : ans)
                cout<<x<<"\n";
            return 0;
        }
    }


    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1755ms
memory: 3720kb

input:

2
0.909840249060
0.414958698174

output:


result:

wrong output format Unexpected end of file - int32 expected