QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#301501#2731. Cartesian ConquestCamillus0 0ms3664kbC++201.2kb2024-01-09 23:42:492024-01-09 23:42:49

Judging History

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

  • [2024-01-09 23:42:49]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3664kb
  • [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

output:


result: