QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372985 | #5271. Focusing on Costs | FOY# | WA | 0ms | 3808kb | C++23 | 1.7kb | 2024-03-31 22:15:54 | 2024-03-31 22:15:55 |
Judging History
answer
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
using pii = pair<int, int>;
class Trans {
virtual string getName() = 0;
virtual pii act(pii cur) = 0;
};
int transCount = 6;
pii act(pii cur, int type) {
auto [a, b] = cur;
if (type == 0)
return {b - a, b};
if (type == 1)
return {a, b - a};
if (type == 2)
return {b - a, a};
if (type == 3)
return {b - a, b};
if (type == 4)
return {a, b + a};
if (type == 5)
return {b, a+b};
}
string getName(int type) {
if (type == 0) return "asin cos";
if (type == 1) return "asin tan";
if (type == 2) return "acos tan";
if (type == 3) return "acos sin";
if (type == 4) return "atan sin";
if (type == 5) return "atan cos";
}
int main() {
map<pii, pair<pii, int>> vis;
queue<pii> cur;
cur.push({0, 1});
int a, b; cin >> a >> b;
for (int i = 1; i <= min(a,b); i++) {
if (a%i == 0 && b%i == 0) {
a/=i;
b/=i;
}
}
while (vis.count({a*a, b*b}) == 0) {
auto front = cur.front();
cur.pop();
if (front.first*front.first > 1e4 || front.second*front.second > 1e4) continue;
for (int t = 0; t < transCount; t++) {
auto to = act(front, t);
if (to.second <= 0) continue;
if (vis.count(to) == 0) {
vis[to] = {front, t};
cur.push(to);
}
}
}
pii end = {a*a, b*b};
//cout << end.first << ' ' << end.second << endl;
vector<string> path;
while (end != make_pair(0, 1)) {
//cout << end.first << ' ' << end.second << endl;
path.push_back(getName(vis[end].second));
end = vis[end].first;
}
cout << 2*path.size() << endl;
for (int i = 0; i < path.size(); i++) cout << path[i]<< ' ';
cout <<endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
input:
1 1
output:
2 asin cos
result:
ok OK, a/b = 1/1, ops = 2, error = 0.000000e+00
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3808kb
input:
2 1
output:
12 acos tan atan sin atan sin atan sin atan sin asin cos
result:
wrong answer Final result is 0.8660254038, expected 2.0000000000, absolute error = 1.1339745962