import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int max =n*m;
//System.out.println(max);
for (int i = max; i >0 ; i--) {
if(istrit_m(i,n,m)==false || istrit_n(i,n,m) ==false){
System.out.println(i);
break;
}
}
}
public static boolean istrit_n(int num,int n,int m){
while (num>0){
if (num%n==0 || num%m==0){
return true;
}else{
num = num-n;
//System.out.println("whiel");
}
}
return false;
}
public static boolean istrit_m(int num,int n,int m){
while (num>0){
if (num%n==0 || num%m==0){
return true;
}else{
num = num-m;//System.out.println("whiel");
}
}
return false;
}
}
1205. 买不到的数目
最新推荐文章于 2024-10-17 19:11:48 发布