QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#135844 | #5253. Denormalization | LeticiaFCS | WA | 1757ms | 3596kb | C++20 | 1.5kb | 2023-08-06 08:37:23 | 2023-08-06 08:37:25 |
Judging History
answer
#include"bits/stdc++.h"
using lint = int64_t;
constexpr int MOD = int(1e9) + 7;
constexpr int INF = 0x63636363;
constexpr int NINF = 0xcfcfcfcf;
constexpr lint LINF = 0x6363636363636363;
using namespace std;
using ld = long double;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int n; cin>>n;
vector<ld> v(n);
for(int i = 0; i<n; i++){
cin>>v[i];
}
ld mini = v[0], maxi = v[0];
for(int i = 0; i<n; i++){
mini = min(mini, v[i]);
maxi = max(maxi, v[i]);
}
sort(v.begin(), v.end());
tuple<ld, int, int> candidate = {1e8,1,1};
ld frac = mini / maxi;
for(int p=1; p<=10000; p++)
for(int q = p; q<=10000; q++){
if(__gcd(p, q) == 1){
candidate = min(candidate, tuple<ld, int, int>(abs(frac - ld(p)/q), p, q));
}
}
int p = get<1>(candidate);
for(int k = 1; p * k <= 10000; k++){
int x = p * k;
ld d = ld(x) / mini;
bool ok = true;
vector<int> ans(n);
for(int i =0; i<n && ok; i++){
/*
v[i] = ans[i] / d
ans[i] = v[i] * d
*/
int cur = v[i] * d;
ans[i] = cur;
if(cur > 10000) ok = false;
if(abs(ld(cur) - v[i] * d) > 1e-6)
ok = false;
}
if(ok){
for(int x : ans)
cout<<x<<"\n";
return 0;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1757ms
memory: 3596kb
input:
2 0.909840249060 0.414958698174
output:
4408 9665
result:
wrong answer incorrect solution