QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#102477#5253. Denormalizationzswzswzsw#Compile Error//C++14945b2023-05-03 13:45:302023-05-03 13:45:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 13:45:32]
  • 评测
  • [2023-05-03 13:45:30]
  • 提交

answer

#include<iostream>
#include<cstring>
using namespace std;
const int N=1e4+10;
double eps=1e-3,ep=1e-5;
long double x[N];
int a[N];
int n;

int _gcd(int x,int y){
    return y?_gcd(y,x%y):x;
}

bool test(long double d){
    long double rel=0;
    int gcd=0;
    for(int i=1;i<=n;++i)
        a[i]=x[i]*d+0.1,
        gcd=(gcd==0?a[i]:_gcd(gcd,a[i]));
    for(int i=1;i<=n;++i)
        a[i]/=gcd,
        rel+=a[i]*a[i];
    rel=sqrt(rel);
    for(int i=1;i<=n;++i)
        if(abs(a[i]/rel-x[i])>ep)
            return false;
    for(int i=1;i<=n;++i)
        cout<<a[i]<<endl;
    return true;
}

long double res(long double x){
    return abs(x-(long long)(x+0.1));
}

int main(){
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>x[i];
    for(int i=1;i<=10000;++i){
        if(i<=10)
        if(res(i*i/x[1]/x[1])<eps)
            if(test(i/x[1])){
                return 0;
            }
    }
}

Details

answer.code: In function ‘bool test(long double)’:
answer.code:23:9: error: ‘sqrt’ was not declared in this scope
   23 |     rel=sqrt(rel);
      |         ^~~~