QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109239#6395. Equation DiscoveringtarjenWA 349ms234048kbC++172.2kb2023-05-27 23:40:292023-05-27 23:40:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-27 23:40:32]
  • 评测
  • 测评结果:WA
  • 用时:349ms
  • 内存:234048kb
  • [2023-05-27 23:40:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long double lf;
typedef vector<lf> Poly;
Poly operator+(Poly a, Poly b) { 
    Poly res((int)a.size());
    for(int i=0;i<(int)a.size();i++)res[i]=a[i]+b[i];
    return res;
}
Poly operator-(Poly a, Poly b) { 
    Poly res((int)a.size());
    for(int i=0;i<(int)a.size();i++)res[i]=a[i]-b[i];
    return res;
}
Poly operator*(Poly a, Poly b) { 
    Poly res((int)a.size());
    for(int i=0;i<(int)a.size();i++)res[i]=a[i]*b[i];
    return res;
}
Poly operator/(Poly a, Poly b) { 
    Poly res((int)a.size());
    Poly Empty;
    for(int i=0;i<(int)a.size();i++){
        if(b[i]==0)return Empty;
        res[i]=a[i]/b[i];
    }
    return res;
}
bool operator==(Poly a, Poly b) { 
    for(int i=0;i<(int)a.size();i++){
        if(fabs(a[i]-b[i])>0.02)return false;
    }
    return true;
}
Poly Sin(Poly &a){
    Poly res((int)a.size());
    for(int i=0;i<(int)a.size();i++)res[i]=sin(a[i]);
    return res;
}
Poly Cos(Poly &a){
    Poly res((int)a.size());
    for(int i=0;i<(int)a.size();i++)res[i]=cos(a[i]);
    return res;
}
vector<pair<string,Poly>> v[10];
string bracket(string s){
    return "("+s+")";
}
int main()
{
    int n;cin>>n;
    Poly a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    string s="x";
    v[0].emplace_back(s,a);
    for(int i=1;i<=9;i++){
        for(int j=0;j+2<=i;j++){
            for(auto &[s1,p1]:v[j]){
                for(auto &[s2,p2]:v[i-j-2]){
                    v[i].emplace_back(bracket(s1+"+"+s2),p1+p2);
                    v[i].emplace_back(bracket(s1+"-"+s2),p1-p2);
                    v[i].emplace_back(bracket(s1+"*"+s2),p1*p2);
                    v[i].emplace_back(bracket(s1+"/"+s2),p1/p2);
                    if(v[i].back().second.size()==0)v[i].pop_back();
                }
            }            
        }
        for(auto &[s1,p1]:v[i-1]){
            v[i].emplace_back("sin("+s1+")",Sin(p1));
            v[i].emplace_back("cos("+s1+")",Cos(p1));
        }
    }
    for(int i=0;i<=9;i++){
        for(auto &[s,p]:v[i]){
            if(p==b){
                cout<<s;
                return 0;
            }
            // cout<<s<<"\n";
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 130ms
memory: 93988kb

input:

3
1.000000 1.000000
2.000000 4.000000
3.000000 9.000000

output:

(x*x)

result:

ok great!!

Test #2:

score: 0
Accepted
time: 118ms
memory: 94904kb

input:

3
0.618000 1.517072
0.314000 3.132637
1.414000 0.494016

output:

(sin(x)/(x*x))

result:

ok great!!

Test #3:

score: 0
Accepted
time: 148ms
memory: 110516kb

input:

5
77.685777 233.057331
-66.445083 -199.335249
79.966717 239.900151
84.982130 254.946390
-31.528900 -94.586700

output:

(x+(x+x))

result:

ok great!!

Test #4:

score: 0
Accepted
time: 152ms
memory: 110652kb

input:

5
25.032427 -0.100652
38.727324 1.658518
27.684334 -0.669555
64.282391 8.275303
52.640700 -0.962660

output:

(sin(x)/cos(x))

result:

ok great!!

Test #5:

score: 0
Accepted
time: 139ms
memory: 110504kb

input:

5
78.611917 -0.992212
-29.857271 1.011993
-75.513655 1.006611
68.512394 1.145128
7.961096 0.881661

output:

(cos(x)+(sin(x)*sin(x)))

result:

ok great!!

Test #6:

score: 0
Accepted
time: 146ms
memory: 110672kb

input:

5
-78.733375 0.503570
-20.187183 0.735779
-38.984992 0.730890
47.859232 0.622831
-19.657164 0.641512

output:

sin(sin(cos(cos(x))))

result:

ok great!!

Test #7:

score: 0
Accepted
time: 167ms
memory: 110476kb

input:

5
3.241091 -32.628130
-83.514144 86.463432
33.586619 40.691607
41.123543 -147.352644
26.896326 27.404018

output:

(x/sin(x))

result:

ok great!!

Test #8:

score: 0
Accepted
time: 349ms
memory: 234048kb

input:

20
-4.908422 -0.693287
3.569189 0.328182
1.946572 -0.667466
6.515336 -0.829948
-1.394076 0.752980
6.722989 0.831881
1.241795 0.835231
-2.443177 -0.143098
-4.180762 -0.803482
1.511247 0.589509
0.627755 0.554244
-1.865604 -0.470029
-4.756347 -0.656984
1.850611 -0.426016
6.580133 -0.474416
6.861815 -0....

output:

sin(sin((x/sin((x/(x*x))))))

result:

ok great!!

Test #9:

score: -100
Wrong Answer
time: 302ms
memory: 233516kb

input:

20
76.797930 0.000002
-76.263778 -0.000002
55.449039 0.000006
10.462093 0.000873
-78.051671 -0.000002
-52.781249 -0.000007
47.053973 0.000010
96.629212 0.000001
-40.697847 -0.000015
31.141805 0.000033
-87.087384 -0.000002
-54.709885 -0.000006
-65.741847 -0.000004
-87.430820 -0.000001
9.420126 0.0011...

output:

(sin(x)/(x*x))

result:

wrong answer fail to discover