You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
470 B
27 lines
470 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
int p, q, res;
|
|
/*
|
|
测试数据:
|
|
4 7
|
|
|
|
根据公式,最大无法凑出的是:4*7-4-7=17
|
|
*/
|
|
bool dfs(int x) {
|
|
if (x == 0) return true;
|
|
if (x >= p && dfs(x - p)) return true;
|
|
if (x >= q && dfs(x - q)) return true;
|
|
return false;
|
|
}
|
|
|
|
int main() {
|
|
scanf("%d %d", &p, &q);
|
|
|
|
for (int i = 1; i <= 1000; i++)
|
|
if (!dfs(i)) res = i;
|
|
|
|
printf("%d\n", res);
|
|
return 0;
|
|
}
|