QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#242614#6395. Equation Discoveringucup-team902WA 31ms41600kbC++171.4kb2023-11-07 15:42:562023-11-07 15:42:56

Judging History

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

  • [2023-11-07 15:42:56]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:41600kb
  • [2023-11-07 15:42:56]
  • 提交

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;
            }
        }
    }
}

详细

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