QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#737437 | #9622. 有限小数 | joso | WA | 0ms | 3496kb | C++14 | 1.0kb | 2024-11-12 15:50:45 | 2024-11-12 15:50:47 |
Judging History
answer
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
using i64 = long long;
using d128 = long double;
void breakdown(i64 x, std::vector<int> &result) {
for (int i = 2; i <= x / i; i ++)
if (x % i == 0) {
result.push_back(i);
while(x % i == 0) x /= i;
}
if (x > 1) result.push_back(x);
}
void solve() {
i64 a, b;
std::cin >> a >> b;
std::vector<int> bs;
breakdown(b, bs);
bool flag = true;
for (auto i : bs) {
if (i != 2 && i != 5) {
flag = false;
break;
}
}
if (flag) {
std::cout << 0 << ' ' << b << '\n';
return;
}
std::cout << i64(ceill((d128)a / (d128)(b))) * b - a << ' ' << b << std::endl;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T;
std::cin >> T;
while (T --) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3496kb
input:
4 1 2 2 3 3 7 19 79
output:
0 2 1 3 4 7 60 79
result:
wrong answer Jury found better answer than participant's 1 < 4 (Testcase 3)