zoj 1003
#include <iostream> #include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <string.h>
#include <cstdio>
using namespace std;
int win;
void solve(int a, int b, int s) {
if ( win == 1 ) return;
if ( a == 1 && b == 1 ) {
win = 1;
return;
}
if ( s == 101 ) {
if ( a == 1 && b > 1 )
win = 0;
return;
}
if ( a % s == 0 ) solve(a / s, b, s + 1);
if ( b % s == 0 ) solve(a, b / s, s + 1);
solve(a, b, s + 1);
}
int main() {
int n, m;
while (scanf("%d%d", &n, &m) != EOF) {
win = -1;
solve(min(n, m), max(n, m), 2);
if ( win != 0 ) {
printf("%d\n", max(n, m));
}
else {
printf("%d\n", min(n, m));
}
}
return 0;
}
谁能告诉我这这个solve函数到底是什么意思?你们为什么能想到呢?如何想到的