QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756224 | #5141. Identical Parity | shunhualin | WA | 0ms | 3600kb | C++20 | 1.0kb | 2024-11-16 19:24:23 | 2024-11-16 19:24:28 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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]