QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#301501 | #2731. Cartesian Conquest | Camillus | 0 | 0ms | 3664kb | C++20 | 1.2kb | 2024-01-09 23:42:49 | 2024-01-09 23:42:49 |
answer
#include "bits/stdc++.h"
using namespace std;
int mx_func(int n, int m) {
int cur = 0;
if (n % 2 == 0 && m - n / 2 > 0) {
cur = max(cur, mx_func(n, m - n / 2));
}
if (m % 2 == 0 && n - m / 2 > 0) {
cur = max(cur, mx_func(n - m / 2, m));
}
if (m - 2 * n > 0) {
cur = max(cur, mx_func(n, m - 2 * n));
}
if (n - 2 * m > 0) {
cur = max(cur, mx_func(n - 2 * m, m));
}
return cur + 1;
}
int mn_func(int n, int m) {
if (n == 2 * m || m == 2 * n) {
return 1;
}
int cur = INT32_MAX;
if (n % 2 == 0 && m - n / 2 > 0) {
cur = min(cur, mn_func(n, m - n / 2));
}
if (m % 2 == 0 && n - m / 2 > 0) {
cur = min(cur, mn_func(n - m / 2, m));
}
if (m - 2 * n > 0) {
cur = min(cur, mn_func(n, m - 2 * n));
}
if (n - 2 * m > 0) {
cur = min(cur, mn_func(n - 2 * m, m));
}
return cur + 1;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
cout << mn_func(n, m) << ' ' << mx_func(n, m) << '\n';
return 0;
}
詳細信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 5
Accepted
time: 0ms
memory: 3552kb
input:
2 1
output:
1 1
result:
ok single line: '1 1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
2 4
output:
1 4
result:
ok single line: '1 4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
5 4
output:
4 4
result:
ok single line: '4 4'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
4 6
output:
3 6
result:
ok single line: '3 6'
Test #5:
score: -5
Time Limit Exceeded
input:
1000 2
output:
result:
Subtask #2:
score: 0
Time Limit Exceeded
Test #20:
score: 0
Time Limit Exceeded
input:
2 1001
output:
result:
Subtask #3:
score: 0
Runtime Error
Test #45:
score: 0
Runtime Error
input:
100000000 2