解题思路:
注意事项:
参考代码:
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt(); // 输入数字 m
int k = sc.nextInt(); // 输入数字 k
sc.close();
String str = String.valueOf(m); // 将数字 m 转换为字符串
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == '3') {
count++; // 统计字符串中 3 的数量
}
}
boolean divisible = (m % 19 == 0); // 判断是否能被19整除
boolean match = (count == k); // 判断是否恰好含有 k 个 3
if (divisible && match) {
System.out.println("YES"); // 满足条件
} else {
System.out.println("NO"); // 不满足条件
}
}
}
0.0分
1 人评分