QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#242645#6395. Equation Discoveringucup-team902WA 0ms4064kbC++171.6kb2023-11-07 16:00:272023-11-07 16:00:28

Judging History

你现在查看的是最新测评结果

  • [2023-11-07 16:00:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4064kb
  • [2023-11-07 16:00:27]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define db float
#define mp make_pair
#define ep emplace_back

valarray<db> x_arr;
valarray<db> y_arr;

vector<pair<string, valarray<db>>> expr[10];

inline bool check(valarray<db> &arr){
    for(int i = 0; i < x_arr.size(); ++i) if(abs(arr[i] - y_arr[i]) > max(abs(y_arr[i]), 1.0f) * 1e-3) return 0;
    return 1;
}

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("%f%f", &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(check(y_arr)){
                printf("%s\n", f.c_str());
                return 0;
            }
        }
    }
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4064kb

input:

3
1.000000 1.000000
2.000000 4.000000
3.000000 9.000000

output:

sin(x)

result:

wrong answer fail to discover