QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#740724#9622. 有限小数toviWA 0ms3532kbC++14668b2024-11-13 11:16:562024-11-13 11:16:56

Judging History

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

  • [2024-11-13 11:16:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-11-13 11:16:56]
  • 提交

answer

#include <iostream>
using namespace std;

// 将一个数分解质因数,只保留2和5,返回其余部分
int reduceToTwoAndFive(int n) {
    while (n % 2 == 0) n /= 2;
    while (n % 5 == 0) n /= 5;
    return n;
}

int main() {
    int T;
    cin >> T;
    while (T--) {
        int a, b;
        cin >> a >> b;

        // 通过分解b来决定d
        int reduced_b = reduceToTwoAndFive(b);

        // 如果 reduced_b 为 1,说明 b 已经只含有 2 和 5 的因数
        // 我们可以直接选择 d = 1, c = 0
        int c = 0;
        int d = reduced_b;

        cout << c << " " << d << endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3532kb

input:

4
1 2
2 3
3 7
19 79

output:

0 1
0 3
0 7
0 79

result:

wrong answer The result is not terminating.(Testcase 2)