QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#842948 | #9969. Kindergarten Square | ucup-team4435# | RE | 1ms | 3512kb | C++20 | 905b | 2025-01-04 16:08:03 | 2025-01-04 16:08:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define len(a) int((a).size())
void solve(int /* test_num */) {
int A, B, C, D;
cin >> A >> B >> C >> D;
A--, B--, C--, D--;
int m = C - A;
for (int n = 2; n <= int(1e5); n++) {
bool ok = true;
ok &= A / m == B / m;
ok &= C / m == D / m;
ok &= B % m == A % m + 1;
ok &= D % m == C % m + 1;
ok &= C / m == A / m + 1;
ok &= max({A, B, C, D}) < 1ll * n * m;
if (ok) {
cout << n << ' ' << m << '\n';
return;
}
}
cout << "-1\n";
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int tests;
cin >> tests;
for (int test_num = 1; test_num <= tests; test_num++) {
solve(test_num);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3512kb
input:
4 6 7 10 11 2 3 4 5 8 5 5 13 1 2 5 6
output:
3 4 -1 -1 2 4
result:
ok All testcases passed.
Test #2:
score: -100
Runtime Error
input:
10 1 2 4 5 4 3 2 1 1 2 5 6 2 3 5 6 2 3 6 7 3 4 6 7 2 1 3 4 1 2 2 3 2 3 3 4 7 7 7 7