QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#537478#5253. DenormalizationUESTC_DECAYALI#WA 5ms4008kbC++201.1kb2024-08-30 14:11:592024-08-30 14:12:06

Judging History

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

  • [2024-08-30 14:12:06]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:4008kb
  • [2024-08-30 14:11:59]
  • 提交

answer

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

using LD = double;

const int N = 1e4+5;
const LD eps = 5e-7;
int n, r[N], ans[N];
LD A[N], rt[N];

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

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

    LD res = 0;

    for (int i=1; i<=n; ++i){
        res = max(abs(rt[i] - A[i]), res);
    }

    return res;
}

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

    LD minv = 1e30;
    for (int i=1; i<=10000; ++i){
        LD res = i / A[mx];
        for (int j=1; j<=n; ++j) r[j] = round(A[j]*res);
        LD rs = check();
        if(rs < minv) minv = rs, memcpy(ans, r, sizeof(int) * (n + 1));
    }

    // std::cerr << "Error = " << minv << char(10);

    int g = ans[1];
    for(int i=1; i<=n; ++i) g = __gcd(g, ans[i]);

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

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3912kb

input:

2
0.909840249060
0.414958698174

output:

9665
4408

result:

ok good solution

Test #2:

score: 0
Accepted
time: 1ms
memory: 3852kb

input:

3
0.005731604132
0.696198848562
0.717826101486

output:

75
9110
9393

result:

ok good solution

Test #3:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

10
0.338936215010
0.390914583549
0.048893426174
0.446152513833
0.137891103101
0.017985796057
0.459132554353
0.201452557127
0.362800863500
0.358493585479

output:

5823
6716
840
7665
2369
309
7888
3461
6233
6159

result:

ok good solution

Test #4:

score: -100
Wrong Answer
time: 5ms
memory: 4008kb

input:

100
0.027828573352
0.034289446708
0.021442608673
0.002752893865
0.091163859407
0.180717182268
0.012097751269
0.101332712254
0.087249881055
0.112643922419
0.016667180541
0.108449036530
0.050488448020
0.104216696303
0.120734059490
0.090096410766
0.066537631979
0.046668105514
0.174836851156
0.084908984...

output:

1189
1465
916
118
3894
7720
517
4329
3727
4812
712
4633
2157
4452
5158
3849
2842
1994
7469
3627
4242
154
4066
46
1150
3783
3019
434
4701
1313
4459
1154
7499
6168
7656
1130
2443
317
2214
6453
1419
1237
7638
1237
6671
329
3090
2797
2734
6532
3808
6263
3767
6539
7053
3517
6249
6518
2366
991
1486
3489
9...

result:

wrong answer incorrect solution