QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#756861#5141. Identical ParityPHarrWA 0ms3616kbC++231.3kb2024-11-16 22:19:432024-11-16 22:19:43

Judging History

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

  • [2024-11-16 22:19:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-11-16 22:19:43]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using i64 = long long;

#define int i64
using vi = vector<int>;
using pii = pair<int, int>;

int exgcd(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    int d = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

void solve() {
    int n, k;
    cin >> n >> k;
    if(k % 2 == 0) {
        cout << "Yes\n";
        return ;
    }
    int m = (n + 1) / 2;
    int a = (n + k - 1) / k, b = n / k;
    int p = n % k, q = k - p; // p is max x, q is max y

    int x, y;
    int d = exgcd(a, b, x, y);
    if (m % d != 0) {
        cout << "No\n";
        return;
    }
    x = x * m / d, y = y * m / d;
    cout << x << " " << y << "\n";
    int dx = b / d, dy = a / d;
    while(x >= dx) x -= dx, y += dy;
    while(x < 0) x += dx, y -= dy;
    while (x <= q) {
        if(x + y > k) continue;
        if (0 <= y and y <= q) {
            cout << "Yes\n";
            return;
        }
        x += dx, y -= dy;
    }
    cout << "No\n";
    return;
}

i32 main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int T;
    cin >> T;
    while (T--)
        solve();

    return 0;
}

詳細信息

Test #1:

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

input:

3
3 1
4 2
5 3

output:

No
Yes
0 3
Yes

result:

wrong output format YES or NO expected, but 0 found [3rd token]