QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#504805 | #9136. Exponent Calculator | ucup-team2307# | AC ✓ | 1ms | 3816kb | C++20 | 2.3kb | 2024-08-04 16:10:53 | 2024-08-04 16:10:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define fi first
#define se second
#define pb push_back
//typedef long double ld;
//#define double ld
const int N = 16;
vector<double> a(N, 0.0);
vector<string> ans;
void mul(int x, int y, int z)
{
stringstream ss;
ss<<fixed<<setprecision(20);
ss<<"$"<<z<<" = $"<<x<<" * $"<<y;
ans.pb(ss.str());
a[z] = a[x] * a[y];
}
void mulby(int x, double y, int z)
{
stringstream ss;
ss<<fixed<<setprecision(20);
ss<<"$"<<z<<" = $"<<x<<" * "<<y;
ans.pb(ss.str());
a[z] = a[x] * y;
}
void add(int x, int y, int z)
{
stringstream ss;
ss<<fixed<<setprecision(20);
ss<<"$"<<z<<" = $"<<x<<" + $"<<y;
ans.pb(ss.str());
a[z] = a[x] + a[y];
}
void eq(int x, double y)
{
stringstream ss;
ss<<fixed<<setprecision(20);
ss<<"$"<<x<<" = "<<y;
ans.pb(ss.str());
a[x] = y;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cout<<fixed<<setprecision(20);
string s;
cin>>s;
double x = 20;
a[1] = x;
int L = 10;
mulby(1, 1.0/(1<<L), 1);
eq(0, 1);
mul(1, 1, 2);
add(0, 1, 0);
mulby(2, 1.0/2, 3);
add(0, 3, 0);
// for (int i=0; i<=3; i++)
// cout<<a[i]<<"\n";
// cout<<"\n";
mul(2, 1, 2);
mulby(2, 1.0/6, 3);
add(0, 3, 0);
// for (int i=0; i<=3; i++)
// cout<<a[i]<<"\n";
// cout<<"\n";
mul(2, 1, 2);
mulby(2, 1.0/24, 3);
add(0, 3, 0);
// for (int i=0; i<=3; i++)
// cout<<a[i]<<"\n";
// cout<<"\n";
mul(2, 1, 2);
mulby(2, 1.0/120, 3);
add(0, 3, 0);
// for (int i=0; i<=3; i++)
// cout<<a[i]<<"\n";
// cout<<"\n";
// mul(2, 1, 2);
// mulby(2, 1.0/720, 3);
// add(0, 3, 0);
//
// mul(2, 1, 2);
// mulby(2, 1.0/720/7, 3);
// add(0, 3, 0);
for (int i=0; i<L; i++)
mul(0, 0, 0);
// for (int i=0; i<=3; i++)
// cout<<a[i]<<"\n";
//
// double y = exp(x);
// cout<<abs(y - a[0])/y<<"\n";
// cout<<abs(y - a[0])/y*1e9<<"\n";
// cout<<ans.size()<<"\n";
cout<<ans.size()<<"\n";
for (string s : ans)
cout<<s<<"\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
input:
input
output:
25 $1 = $1 * 0.00097656250000000000 $0 = 1.00000000000000000000 $2 = $1 * $1 $0 = $0 + $1 $3 = $2 * 0.50000000000000000000 $0 = $0 + $3 $2 = $2 * $1 $3 = $2 * 0.16666666666666665741 $0 = $0 + $3 $2 = $2 * $1 $3 = $2 * 0.04166666666666666435 $0 = $0 + $3 $2 = $2 * $1 $3 = $2 * 0.00833333333333333322 ...
result:
ok max relative diff is 8.04772e-11. Checker runtime is 200 ms
Extra Test:
score: 0
Extra Test Passed