QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#242614 | #6395. Equation Discovering | ucup-team902 | WA | 31ms | 41600kb | C++17 | 1.4kb | 2023-11-07 15:42:56 | 2023-11-07 15:42:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define db double
#define mp make_pair
#define ep emplace_back
valarray<db> x_arr;
valarray<db> y_arr;
vector<pair<string, valarray<db>>> expr[10];
int main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
int n; scanf("%d", &n);
x_arr.resize(n);
y_arr.resize(n);
for(int i = 0; i < n; ++i){
db x, y; scanf("%lf%lf", &x_arr[i], &y_arr[i]);
}
expr[0].ep(mp("x", x_arr));
for(int i = 1; i <= 9; ++i){
for(auto &[f, y]: expr[i - 1]){
expr[i].ep(mp("sin(" + f + ")", sin(y)));
expr[i].ep(mp("cos(" + f + ")", cos(y)));
}
for(int j = 0; j < i - 1; ++j){
for(auto &[f1, y1] : expr[j]){
for(auto &[f2, y2] : expr[i - j - 2]){
expr[i].ep(mp("(" + f1 + "+" + f2 + ")", y1 + y2));
expr[i].ep(mp("(" + f1 + "-" + f2 + ")", y1 - y2));
expr[i].ep(mp("(" + f1 + "*" + f2 + ")", y1 * y2));
if(abs(y2).min() < 0.01){
expr[i].ep(mp("(" + f1 + "/" + f2 + ")", y1 / y2));
}
}
}
}
for(auto &[f, y]: expr[i]){
if(abs(y_arr - y).max() < 1e-4){
printf("%s\n", f.c_str());
return 0;
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4360kb
input:
3 1.000000 1.000000 2.000000 4.000000 3.000000 9.000000
output:
(x*x)
result:
ok great!!
Test #2:
score: -100
Wrong Answer
time: 31ms
memory: 41600kb
input:
3 0.618000 1.517072 0.314000 3.132637 1.414000 0.494016
output:
result:
wrong output format Unexpected end of file - token expected