QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372983 | #5271. Focusing on Costs | FOY# | WA | 0ms | 3528kb | C++23 | 1.7kb | 2024-03-31 22:10:48 | 2024-03-31 22:10:49 |
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) {
if (type == 0)
return {cur.second - cur.first, cur.second};
if (type == 1)
return {cur.first, cur.second - cur.first};
if (type == 2)
return {cur.second - cur.first, cur.first};
if (type == 3)
return {cur.second - cur.first, cur.second};
if (type == 4)
return {cur.first, cur.second + cur.first};
if (type == 5)
return {cur.second, cur.first+cur.second};
}
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 (vis.count(to) == 0) {
vis[to] = {front, t};
cur.push(to);
}
}
}
pii end = {a*a, b*b};
vector<string> path;
while (end != make_pair(0, 1)) {
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: 3528kb
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: 3512kb
input:
2 1
output:
10 asin cos acos tan asin tan asin tan acos tan
result:
wrong answer Final result is 16331239353195370.0000000000, expected 2.0000000000, absolute error = 16331239353195368.0000000000