希望大佬们能写点难题的阅读性好点的题解 QAQ
import java.util.Scanner;
public class Main {
static String PAY_MORE = "Happy birthday to MFGG";
static String PAY_LESS = "Happy birthday to YXGG";
static String PAY = "PLMM";
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a1 = sc.next();
String a2 = sc.next();
// 小数部分大于 0.5
if (a2.matches("(5\\d*[^0]\\d*)|([6-9]\\d*)")) {
System.out.println(PAY_MORE);
// 小数部分小于 0.5
} else if (a2.charAt(0) < '5') {
if (a2.charAt(0) == '0') {
System.out.println(PAY);
} else {
System.out.println(PAY_LESS);
}
// 等于0.5
} else {
if (((a1.charAt(a1.length() - 1) - '0') & 1) == 0) {
System.out.println(PAY_LESS);
} else {
System.out.println(PAY_MORE);
}
}
}
}