QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#89676 | #5253. Denormalization | CCSU_Wine | RE | 3ms | 3504kb | C++20 | 1.0kb | 2023-03-20 21:42:50 | 2023-03-20 21:42:51 |
Judging History
answer
#include <math.h>
#include <iostream>
using namespace std;
const double eps = 1e-8;
int n, ans[15];
double a[15];
int get(double x, double p1, double p2){
return sqrt(x * p2 / p1) + 0.5; // 四舍五入
}
void get_org(){
int x = ans[1] * ans[1];
for(int i = 2; i <= n; i ++){
ans[i] = get(x, a[1], a[i]);
}
}
bool sgn(double x){
if(fabs(x) <= eps) return true;
return false;
}
bool check(){
double sum = 0.0;
for(int i = 1; i <= n; i ++){
sum += (double)(ans[i] * ans[i]);
}
for(int i = 1; i <= n; i ++){
if(!sgn(a[i] - (double)(ans[i] * ans[i]) / sum)) return false;
}
return true;
}
int main(){
cin >> n;
for(int i = 1; i <= n; i ++){
cin >> a[i];
a[i] *= a[i]; // a[i]^2 代表转化后的数字占总和的比例
}
for(int i = 1; i <= 10000; i ++){ // 枚举a1
ans[1] = i;
get_org();
if(check()) break;
}
for(int i = 1; i <= n; i ++){
cout << ans[i] << "\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3496kb
input:
2 0.909840249060 0.414958698174
output:
8242 3759
result:
ok good solution
Test #2:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
3 0.005731604132 0.696198848562 0.717826101486
output:
75 9110 9393
result:
ok good solution
Test #3:
score: 0
Accepted
time: 3ms
memory: 3504kb
input:
10 0.338936215010 0.390914583549 0.048893426174 0.446152513833 0.137891103101 0.017985796057 0.459132554353 0.201452557127 0.362800863500 0.358493585479
output:
5823 6716 840 7665 2369 309 7888 3461 6233 6159
result:
ok good solution
Test #4:
score: -100
Runtime Error
input:
100 0.027828573352 0.034289446708 0.021442608673 0.002752893865 0.091163859407 0.180717182268 0.012097751269 0.101332712254 0.087249881055 0.112643922419 0.016667180541 0.108449036530 0.050488448020 0.104216696303 0.120734059490 0.090096410766 0.066537631979 0.046668105514 0.174836851156 0.084908984...