题目描述
小蓝正在上小学,老师要求同学们在暑假每天记日记。可是小蓝整个暑假都在玩,直到最后一天才想起要记日记。于是小蓝赶紧编了一些日记交给老师。
没想到,日记很快就被老师发现了问题,原来小蓝记完 8 月 31 日的日记,竟又记了 8 月 32 日和 8 月 33 日的日记。这显然是有问题的,因为根本没有 8 月 32 日和 8 月 33 日。
给定一个月份和一个日期,请问 2021 年有没有这一天。
输入描述
输入的第一行包含一个整数 m,表示月份。
第二行包含一个整数 d,表示日期。
其中,1≤m≤20,1≤d≤40。
输出描述
如果2021年有 m 月 d 日,输入 yes
,否则输出 no
。
输入输出样例
示例 1
输入
8
32
输出
no
示例 2
输入
2
28
输出
yes
运行限制
- 最大运行时间:1s
- 最大运行内存: 128M
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int month=scan.nextInt();
int day=scan.nextInt();
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
if(day>=1&&day<=31){
System.out.printf("yes");
}
else{
System.out.printf("no");
}
}
if(month==2){
if(day<=28&&day>=1){
System.out.printf("yes");
}
else{
System.out.printf("no");
}
}
if(month==4||month==6||month==9||month==11){
if(day>=1&&day<=30){
System.out.printf("yes");
}
else{
System.out.printf("no");
}
}
if(month<1||month>12){
System.out.printf("no");
}
}
}