游客 Signup | Login
中文 | En

2444 - 【入门】判断某年某月的天数

输入年,月,然后告诉该月有多少天。

Input

输入只有一行,包括2个整数。之间用一个空格分开。

Output

输出只有一行(这意味着末尾有一个回车符号),包括1个整数。

Examples

Input

2000 2

Output

29

Solution C++

#include <iostream>
using namespace std;
int judge(int year)
 {
  if(year%4==0&&year%100!=0||year%400==0)
	  return 1;
  else
	  return 0;
}
int main()
{
	int n,y,a;
	int r[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int p[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	cin>>n>>y;
	a=judge(n);

	if(a==1)
	    cout<<r[y-1]<<endl;
	else
		cout<<p[y-1]<<endl;
	return 0;

}

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题