QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#242663#6395. Equation Discoveringucup-team902WA 35ms41732kbC++171.6kb2023-11-07 16:12:262023-11-07 16:12:27

Judging History

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

  • [2023-11-07 16:12:27]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:41732kb
  • [2023-11-07 16:12:26]
  • 提交

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