QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#403449 | #6749. Target | ccsu_zx# | WA | 2ms | 4812kb | C++14 | 1.3kb | 2024-05-02 13:21:28 | 2024-05-02 13:21:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 998244353;
const int N = 1e5+10;
int dis[N];
int p[N];
int path[N];
void solve() {
string sa, sb;
int a = 0, b = 0, len;
int i, j;
cin>>sa>>sb;
a = sa[0]-'0';
b = sb[0]-'0';
if (sa.size() == 1) {
sa += '.';
}
if (sb.size() == 1) {
sb += '.';
}
len = max(sa.size(), sb.size());
len = min(len, 7);
for (i = 2; i < sa.size(); i++) {
a = a*10 + sa[i]-'0';
}
while (i < len) {
a = a*10;
i++;
}
for (i = 2; i < sb.size(); i++) {
b = b*10 + sb[i]-'0';
}
while (i < len) {
b = b*10;
i++;
}
for (i = len; i < 7; i++) {
a *= 10;
b *= 10;
}
// printf("a = %d, b= %d\n", a, b);
memset(dis, -1, sizeof(dis));
queue<int> q;
q.push(a);
dis[a] = 0;
while (!q.empty()) {
int u = q.front();
q.pop();
// printf("u = %d\n", u);
int v = u/2;
if (dis[v] == -1) {
p[v] = u;
path[v] = 1;
dis[v] = dis[u]+1;
q.push(v);
}
v = u/2 + 0.5*1e5;
if (dis[v] == -1) {
p[v] = u;
path[v] = 2;
dis[v] = dis[u]+1;
q.push(v);
}
}
while (b != a) {
// printf("b = %d\n", b);
cout<<path[b];
b = p[b];
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
// cin>>T;
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4792kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 4812kb
input:
1 0.75
output:
21
result:
wrong answer wa