QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#135848 | #5253. Denormalization | LeticiaFCS | WA | 1755ms | 3720kb | C++20 | 1.7kb | 2023-08-06 08:54:12 | 2023-08-06 08:54:15 |
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);
//1 6
for(int k = 1; p * k <= 10; k++){
int x = p * k;
/*
v[i] = x / d
d = x / v[i]
*/
ld d = ld(x) / mini;
bool ok = true;
vector<int> ans(n);
ld real_d = 0;
for(int i =0; i<n && ok; i++){
/*
v[i] = ans[i] / d
ans[i] = v[i] * d
*/
ans[i] = round(v[i] * d);
if(ans[i] > 10000) ok = false;
real_d += ans[i] * ans[i];
}
real_d = sqrt(real_d);
for(int i =0; i<n && ok; i++){
if(abs(v[i] - ld(ans[i]) / real_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: 1755ms
memory: 3720kb
input:
2 0.909840249060 0.414958698174
output:
result:
wrong output format Unexpected end of file - int32 expected