QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#135850 | #5253. Denormalization | LeticiaFCS | WA | 1752ms | 3720kb | C++20 | 1.7kb | 2023-08-06 08:54:55 | 2023-08-06 08:55:06 |
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 <= 10000; 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;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1752ms
memory: 3720kb
input:
2 0.909840249060 0.414958698174
output:
4408 9665
result:
wrong answer incorrect solution