wjw最近运气极其差,什么roll点1-100连着十次都是个位数啊,买个珍珠奶茶没有珍珠啊,吃方便面没有调料包啊...
迷信的wjw觉得,一定是因为这个月的13号正好是星期五,才会导致他的运气这么差。
现在他想知道,在某个年份中,有多少个月的13号是星期五,这样他才可以提前做好心理准备。
PS.已知1998年1月1日是星期四,输入的年份肯定大于或等于1998年。
输入
input
输入只有一行,表示年份(大于等于1998年)
输出
output
输出只有一行,表示这一年中有多少个月的13号是星期五
样例输入
1998
样例输出
3
思路:直接从1998年开始模拟,输入的年数尽可能多的减少400年(优化)
AC Code:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#define mod 998244353;
#define Max 0x3f3f3f3f;
#define Min 0xc0c0c0c0;
#define mst(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
using namespace std;
typedef long long ll;
const int maxn=100005;
int year;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
ios::sync_with_stdio(false);
int year_n=1998;
int month_n=1;
int day_n=2;
int sum=0;
cin>>year;
while(year_n!=year+1)
{
if(year_n%4==0 && year_n%100!=0 || year_n%400==0)
{
month[2]=29;
}
else month[2]=28;
day_n += 7;
if(day_n==13 && year_n==year)
{
sum++;
}
/*if(day_n==13)
{
cout<<"符合条件:";
}*/
if(day_n>month[month_n])
{
day_n -=month[month_n];
month_n++;
}
if(month_n>12)
{
month_n=1;
year_n++;
}
//cout<<year_n<<" "<<month_n<<" "<<day_n<<endl;
}
cout<<sum<<endl;
return 0;
}