QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#494338 | #9136. Exponent Calculator | PhantomThreshold# | AC ✓ | 0ms | 3564kb | C++17 | 1.8kb | 2024-07-27 15:19:01 | 2024-07-27 15:19:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
vector<tuple<string,string,int,string>> ans;
typedef long double db;
db reg[20];
int len=0;
db pool[114514];
string tab="+-*";
void output(){
cout << (int)ans.size() << "\n";
for (auto [x,y,op,z]:ans){
if (op==3){
cout << x << " = " << y << "\n";
}
else{
cout << x << " = " << y << " " << tab[op] << " " << z << "\n";
}
}
}
db& get(string A){
if (A[0]=='$'){
string tmp;
for (auto ch:A) if (ch!='$') tmp.push_back(ch);
stringstream ss(tmp);
int ind=0;
ss >> ind;
return reg[ind];
}
else{
stringstream ss(A);
db ret=0;
ss >> ret;
pool[++len]=ret;
return pool[len];
}
}
void check(){
cerr << fixed << setprecision(50) << reg[1] << "\n";
cerr << fixed << setprecision(50) << exp(reg[1]) << "\n";
for (auto [x,y,op,z]:ans){
if (op==3){
get(x)=get(y);
}
else if (op==0){
get(x)=get(y)+get(z);
}
else if (op==1){
get(x)=get(y)-get(z);
}
else if (op==2){
get(x)=get(y)*get(z);
}
}
cerr << fixed << setprecision(50) << reg[0] << "\n";
}
int main(){
{
string str;
cin >> str;
}
ans.emplace_back("$1","$1",2,"0.0001220703125");
ans.emplace_back("$2","$1",0,"0.0");
ans.emplace_back("$0","$2",0,"1.0");
ans.emplace_back("$2","$2",2,"$1");
ans.emplace_back("$2","$2",2,"0.5");
ans.emplace_back("$0","$0",0,"$2");
ans.emplace_back("$2","$2",2,"$1");
ans.emplace_back("$2","$2",2,"0.333333333333333333333333333333");
ans.emplace_back("$0","$0",0,"$2");
ans.emplace_back("$2","$2",2,"$1");
ans.emplace_back("$2","$2",2,"0.25");
ans.emplace_back("$0","$0",0,"$2");
for (int i=1;i<=13;i++){
ans.emplace_back("$0","$0",2,"$0");
}
output();
// reg[1]=-20;
// check();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
input
output:
25 $1 = $1 * 0.0001220703125 $2 = $1 + 0.0 $0 = $2 + 1.0 $2 = $2 * $1 $2 = $2 * 0.5 $0 = $0 + $2 $2 = $2 * $1 $2 = $2 * 0.333333333333333333333333333333 $0 = $0 + $2 $2 = $2 * $1 $2 = $2 * 0.25 $0 = $0 + $2 $0 = $0 * $0 $0 = $0 * $0 $0 = $0 * $0 $0 = $0 * $0 $0 = $0 * $0 $0 = $0 * $0 $0 = $0 * $0 $0...
result:
ok max relative diff is 9.43613e-12. Checker runtime is 193 ms
Extra Test:
score: 0
Extra Test Passed