QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#737437#9622. 有限小数josoWA 0ms3496kbC++141.0kb2024-11-12 15:50:452024-11-12 15:50:47

Judging History

你现在查看的是最新测评结果

  • [2024-11-12 15:50:47]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3496kb
  • [2024-11-12 15:50:45]
  • 提交

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)