好题
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#include <stdlib.h>
#include <stdio.h>
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define l(x) x<<1
#define r(x) x<<1|1
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
int a[111];
int k, l;
int vis, f;
bool get(int now, int mmin, int mmax) {
if (now > 100) return false;
if (mmin == 1) {//选完了一个数,用vis标记已经选完了一个数。
if (vis) return true;
else {
f = vis = true;//f表示有一个数可以分解
if (get(1, mmax, mmax)) return true;
vis = false;
return false;
}
}
else {
for (int i = now; i < 101; i++) {
if (mmin%i == 0 && !a[i]) {
a[i] = true;
if (get(now + 1, mmin / i, mmax)) return true;
a[i] = false;
}
}
return false;
}
}
int main(){
while (cin >> k >> l) {
ms(a, 0);
f = vis = false;
if(get(1, min(k, l), max(k, l)))
cout << max(k, l) << endl;
else {
if(f)
cout << min(k, l) << endl;
else
cout << max(k, l) << endl;
}
}
return 0;
}