QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#756224#5141. Identical ParityshunhualinWA 0ms3600kbC++201.0kb2024-11-16 19:24:232024-11-16 19:24:28

Judging History

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

  • [2024-11-16 19:24:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-11-16 19:24:23]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl "\n"
const int mod = 1e9 + 7;
const int N = 1e5 + 50;
using namespace std;
int Exgcd(int a, int b, int &x, int &y) {
    if (!b) {
        x = 1;
        y = 0;
        return a;
    }
    int d = Exgcd(b, a % b, x, y);
    int t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
}
void slove() {
    int n, k;
    cin >> n >> k;
    int p = n % k, q = k - n % k;
    int a = n / k + 1, b = n / k, c = (n + 1) / 2;
    int x, y;
	int d = Exgcd(a, b, x, y);
	if(c % d != 0){
		cout << "No" << endl;
	}else{
		a = a / d, b = b / d, c = c / d;
		x = x * c, y = y * c;
		int r1 = (p - x) / b;
		int l1 = (-x + b - 1) / b;
		int l2 = (y - q + a - 1) / a;
		int r2 = y / a;
		int l = max(l1, l2), r = min(r1, r2);
		if(l <= r){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int T = 1;
    cin >> T;
    while(T--) {
        slove();
    }
    return 0;
}

详细

Test #1:

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

input:

3
3 1
4 2
5 3

output:

Yes
No
Yes

result:

wrong answer expected NO, found YES [1st token]