QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#660930 | #6749. Target | ucup-team1769# | WA | 0ms | 3876kb | C++20 | 1.1kb | 2024-10-20 13:58:21 | 2024-10-20 13:58:24 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
double a, b;
std::cin >> a >> b;
if (a != b && a == 1.) {
std::cout << 1;
a /= 2;
}
if (a == b) {
return 0;
}
std::vector<int> A, B;
double base = 0.5;
while (A.size() < 40) {
if (a >= base) {
A.emplace_back(1);
a -= base;
} else {
A.emplace_back(0);
}
base /= 2;
}
base = 0.5;
while (B.size() < 40) {
if (b >= base) {
B.emplace_back(1);
b -= base;
} else {
B.emplace_back(0);
}
base /= 2;
}
// std::cerr << "Yes\n";
for (int i = 0, j = 40; i < 40 && j > 0; i++, j--) {
int l = i, r = 0;
while (l < 40 && r < j && A[r] == B[l]) {
l++, r++;
}
// std::cerr << "Yes\n";
if (l == 40 && r == j) {
// std::cerr << i << " " << j << "\n";
for (int _ = i - 1; _ >= 0; _--) {
if (B[_]) {
std::cout << 2;
} else {
std::cout << 1;
}
}
std::cout << "\n";
return 0;
}
}
for (int i = 0; i < 40; i++) {
std::cout << 1;
}
std::cout << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
input:
0.5 0.25
output:
1
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
1 0.75
output:
12
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 0
output:
11111111111111111111111111111111111111111
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
0.361954 0.578805
output:
1112221111112111121121122121111212112
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
0.144888 0.140086
output:
11121211212111212212121122212222111211
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
0.514397 0.969399
output:
21112221121221111211121212121111122222
result:
ok ok
Test #7:
score: -100
Wrong Answer
time: 0ms
memory: 3868kb
input:
0.887873 0.402213
output:
1111111111111111111111111111111111111111
result:
wrong answer wa