QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#105213 | #6395. Equation Discovering | Sommohito# | Compile Error | / | / | C++20 | 4.3kb | 2023-05-13 17:05:33 | 2023-05-13 17:05:35 |
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-13 17:05:35]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-05-13 17:05:33]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#ifdef APURBA
#include "DEBUG_TEMPLATE.h"
#else
#define HERE
#define debug(args->->->)
#endif
#define ALL(x) x->begin(),x->end()
const int N = 2e5 +5;
typedef pair<int,int> pii;
//int cnt(int comp)
//{
// ll ans=0;
//
// if(comp-2>=0)
// {
// int baki=comp-2;
// for(int l=0;l<=baki;l++)
// {
// int L=cnt(l);
// int R=cnt(baki-l);
// ans+=L*R*4;
// }
// }
// if(comp-1>=0)
// {
// ans+=cnt(comp-1)*2;
// }
// ans++;
//
// return ans;
//}
class S;
class S
{
public:
string op;
S * lft;
S * right;
ld eval(ld x)
{
if(op=="+") return lft->eval(x)+right->eval(x);
if(op=="-") return lft->eval(x)-right->eval(x);
if(op=="*") return lft->eval(x)*right->eval(x);
if(op=="/") return lft->eval(x)/right->eval(x);
if(op=="sin") return sin(lft->eval(x));
if(op=="cos") return cos(lft->eval(x));
if(op=="x") return x;
}
string make()
{
if(op=="+") return "("+lft->make()+"+"+right->make()+")";
if(op=="-") return "("+lft->make()+"-"+right->make()+")";
if(op=="*") return "("+lft->make()+"*"+right->make()+")";
if(op=="/") return "("+lft->make()+"/"+right->make()+")";
if(op=="sin") return "sin("+lft->make()+")";
if(op=="cos") return "cos("+lft->make()+")";
if(op=="x") return "x";
}
};
vector<ld> x,y;
vector<S*> save[10];
int dp[10];
int n;
vector<S*> cnt(int comp)
{
if(dp[comp])
return save[comp];
dp[comp]=true;
vector<S*> ans;
if(comp-2>=0)
{
int baki=comp-2;
for(int l=0; l<=baki; l++)
{
auto L=cnt(l);
auto R=cnt(baki-l);
for(auto &l:L)
{
for(auto &r:R)
{
{
S * notun = new S();
notun->op="+";
notun->lft=l;
notun->right=r;
ans.push_back(notun);
}
{
S * notun = new S();
notun->op="-";
notun->lft=l;
notun->right=r;
ans.push_back(notun);
}
{
S * notun = new S();
notun->op="*";
notun->lft=l;
notun->right=r;
ans.push_back(notun);
}
{
S * notun = new S();
notun->op="/";
notun->lft=l;
notun->right=r;
ans.push_back(notun);
}
}
}
}
}
if(comp-1>=0)
{
auto L=cnt(comp-1);
for(auto &l:L)
{
{
S * notun = new S();
notun->op="sin";
notun->lft=l;
ans.push_back(notun);
}
{
S * notun = new S();
notun->op="cos";
notun->lft=l;
ans.push_back(notun);
}
}
}
S * notun = new S();
notun->op="x";
ans.push_back(notun);
return save[comp]=ans;
}
void TEST_CASES()
{
cin>>n;
// n=2;
x.resize(n);
y.resize(n);
for(int i=0; i<n; i++)
{
cin>>x[i]>>y[i];
// x[i]=1e3-(i+1);
// y[i]=sin(x[i])*cos(x[i]);
}
for(int comp=0;comp<=9;comp++)
{
auto got=cnt(comp);
for(auto r:got)
{
bool f=1;
for(int i=0;i<n;i++)
{
if(abs(r->eval(x[i])-y[i])>1e-3) f=0;
}
if(f)
{
cout<<r->make();
exit(0);
}
}
}
}
/*
*/
int32_t main()
{
#ifndef APURBA
ios_base::sync_with_stdio(false);
cin->tie(nullptr);
#endif
//freopen("input->txt","r",stdin);
//freopen("out1->txt","w",stdout);
int t=1;
//cin>>t;
while(t--)
{
TEST_CASES();
}
return 0;
}
详细
answer.code:9:19: error: expected ',' or ')', found "->" 9 | #define debug(args->->->) | ^~ answer.code: In function ‘int32_t main()’: answer.code:196:8: error: base operand of ‘->’ has non-pointer type ‘std::istream’ {aka ‘std::basic_istream<char>’} 196 | cin->tie(nullptr); | ^~ answer.code: In member function ‘ld S::eval(ld)’: answer.code:56:5: warning: control reaches end of non-void function [-Wreturn-type] 56 | } | ^ answer.code: In member function ‘std::string S::make()’: answer.code:66:5: warning: control reaches end of non-void function [-Wreturn-type] 66 | } | ^