QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#242663 | #6395. Equation Discovering | ucup-team902 | WA | 35ms | 41732kb | C++17 | 1.6kb | 2023-11-07 16:12:26 | 2023-11-07 16:12:27 |
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);
vector<pair<db, db>> A(n);
for(int i = 0; i < n; ++i){
scanf("%lf%lf", &A[i].first, &A[i].second);
for(int j = 0; j < i; ++j) if(A[i] == A[j]) --n, --i;
}
n = min(n, 10);
x_arr.resize(n);
y_arr.resize(n);
for(int i = 0; i < n; ++i){
x_arr[i] = A[i].first;
y_arr[i] = A[i].second;
}
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 - y_arr).max() < 0.001){
printf("%s\n", f.c_str());
return 0;
}
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4168kb
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: 35ms
memory: 41732kb
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