QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#763616 | #5141. Identical Parity | shunhualin | Compile Error | / | / | C++20 | 1.3kb | 2024-11-19 21:14:20 | 2024-11-19 21:14:22 |
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;
}
int Ceil(int &a, int &b){
if(b > 0){
return (a + (a > 0 ? b - 1 : 0)) / b;
}else{
return (a + (a > 0 ? 0 : b + 1)) / b;
}
}
int Floor(int &a, int &b){
if(b > 0){
return (a + (a < 0 ? -(b - 1) : 0)) / b;
}else{
return (a + (a < 0 ? 0 : -(b + 1))) / b;
}
}
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 = Floor(p - x), b);
int l1 = Ceil(-x, b);
int l2 = Ceil(y - q), a);
int r2 = Floor(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;
}
详细
answer.code: In function ‘void slove()’: answer.code:45:34: error: cannot bind non-const lvalue reference of type ‘long long int&’ to an rvalue of type ‘long long int’ 45 | int r1 = Floor(p - x), b); | ~~^~~ answer.code:26:16: note: in passing argument 1 of ‘long long int Floor(long long int&, long long int&)’ 26 | int Floor(int &a, int &b){ | ^ answer.code:46:31: error: cannot bind non-const lvalue reference of type ‘long long int&’ to an rvalue of type ‘long long int’ 46 | int l1 = Ceil(-x, b); | ^~ answer.code:19:15: note: initializing argument 1 of ‘long long int Ceil(long long int&, long long int&)’ 19 | int Ceil(int &a, int &b){ | ^ answer.code:47:33: error: cannot bind non-const lvalue reference of type ‘long long int&’ to an rvalue of type ‘long long int’ 47 | int l2 = Ceil(y - q), a); | ~~^~~ answer.code:19:15: note: in passing argument 1 of ‘long long int Ceil(long long int&, long long int&)’ 19 | int Ceil(int &a, int &b){ | ^