QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#666710#5253. Denormalizationjay248Compile Error//C++141.0kb2024-10-22 19:41:362024-10-22 19:41:48

Judging History

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

  • [2024-10-22 19:41:48]
  • 评测
  • [2024-10-22 19:41:36]
  • 提交

answer

#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;
int n;
double x[100005];
double m[100005];

int near(int i){
    for(int c=1; c<=10000; c++){
        double val = m[i] * c;

        if(fabs(val - round(val)) < 1e-9) return c;
    }
    return -1;
}


int gcd(int a, int b){
    if(a > b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    while(b>0){
        int tmp = b;
        b = a%b;
        a = tmp;
    }
    return a;
}

int main(){
    
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>x[i];
    }
    double mn=10000;
    int ind;
    for(int i=0; i<n; i++){
        if(x[i] < mn) {mn = x[i]; ind = i;}
    }

    for(int i=0; i<n; i++){
        m[i] = x[i]/x[ind];
    }
    

    int ans = 1;
    for(int i=0; i<n; i++){
        int mul = near(i);
        ans = (mul * ans)/gcd(mul, ans);
    }

    for(int i=0; i<n; i++){
        cout << static_cast<int>(round(m[i] * ans));
        if(i<n-1) cout<<' ';
    }
}

详细

answer.code: In function ‘int near(int)’:
answer.code:14:23: error: ‘round’ was not declared in this scope
   14 |         if(fabs(val - round(val)) < 1e-9) return c;
      |                       ^~~~~
answer.code:14:12: error: ‘fabs’ was not declared in this scope; did you mean ‘labs’?
   14 |         if(fabs(val - round(val)) < 1e-9) return c;
      |            ^~~~
      |            labs
answer.code: In function ‘int main()’:
answer.code:58:34: error: ‘round’ was not declared in this scope
   58 |         cout << static_cast<int>(round(m[i] * ans));
      |                                  ^~~~~