'commit'
This commit is contained in:
26
TangDou/AcWing/Math/LQBS_MaiBuDaoNum.cpp
Normal file
26
TangDou/AcWing/Math/LQBS_MaiBuDaoNum.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user