QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#666561#5253. Denormalizationjay248WA 0ms3808kbC++14913b2024-10-22 19:04:022024-10-22 19:04:06

Judging History

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

  • [2024-10-22 19:04:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3808kb
  • [2024-10-22 19:04:02]
  • 提交

answer

#include <iostream>
#include <iomanip>

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

int near(int i){
    for(int c=1; c<=10000; c++){
        if(m[i]*c - (int)(m[i]*c) < 0.001 | (int)(m[i]*c)+1 - m[i]*c < 0.001) 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];
    }

    for(int i=0; i<n; i++){
        m[i] = (double)x[i]/(double)x[0];
    }
    cout<<'\n';
    

    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<<(int)(m[i]*ans*1.01);
        if(i<n-1) cout<<' ';
    }
}

详细

Test #1:

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

input:

2
0.909840249060
0.414958698174

output:


298 136

result:

wrong answer the greatest common divisor is 2, but expected 1.