QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#526526 | #5253. Denormalization | solar_express# | WA | 84ms | 3736kb | C++20 | 898b | 2024-08-21 17:02:27 | 2024-08-21 17:02:28 |
Judging History
answer
#include<bits/stdc++.h>
#define N 10005
#define db double
using namespace std;
const db eps=1e-8;
db a[N];
int ans[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
for(int i=1;i<=n;++i)
cin>>a[i];
int pos=0;
for(int i=2;i<=n;++i)
if(a[i]<a[1]-eps||a[1]+eps<a[i]){
pos=i;
break;
}
if(pos==0){
for(int i=1;i<=n;++i)
cout<<"1\n";
return 0;
}
bool fl=1;
for(int i=1;i<=10000&&fl;++i)
for(int j=1;j<=10000&&fl;++j){
db va=a[1]*j,vb=a[pos]*i;
if(fabs(va-vb)<eps){
ans[1]=i/gcd(i,j);
fl=0;
}
}
for(int i=2;i<=n;++i){
ans[i]=int(1ll*ans[1]*a[i]/a[1]+eps);
}
for(int i=1;i<=n;++i)
cout<<ans[i]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 84ms
memory: 3736kb
input:
2 0.909840249060 0.414958698174
output:
9665 4408
result:
ok good solution
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3680kb
input:
3 0.005731604132 0.696198848562 0.717826101486
output:
15 1821 1878
result:
wrong answer the greatest common divisor is 3, but expected 1.