AcWing 1205. 买不到的数目
原题链接
简单
作者:
奋斗吧
,
2020-10-10 16:49:49
,
所有人可见
,
阅读 242
import java.util.*;
public class Main{
static boolean[] div = new boolean[100000001];
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
int min = Math.min(n,m);
int max = Math.max(n,m);
int res = 0;
div[0] = true;
for(int i=min;i<=100000000;i++){
if(div[i-min]==true||(i>=max&&div[i-max]==true)){
div[i] = true;
}else{
div[i] = false;
res=i;
}
}
System.out.print(res);
}
}