QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#666720 | #5253. Denormalization | jay248 | WA | 0ms | 3672kb | C++14 | 1.0kb | 2024-10-22 19:43:37 | 2024-10-22 19:43:45 |
Judging History
answer
#include <iostream>
#include <iomanip>
#include <cmath>
#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<<' ';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3672kb
input:
2 0.909840249060 0.414958698174
output:
-2 -1
result:
wrong answer Integer parameter [name=r_i] equals to -2, violates the range [1, 10000]