As a university advocating self-learning and work-rest balance, Marjar University has so many days of rest, including holidays and weekends. Each weekend, which consists of Saturday and Sunday, is a rest time in the Marjar University.
The May Day, also known as International Workers' Day or International Labour Day, falls on May 1st. In Marjar University, the May Day holiday is a five-day vacation from May 1st to May 5th. Due to Saturday or Sunday may be adjacent to the May Day holiday, the continuous vacation may be as long as nine days in reality. For example, the May Day in 2015 is Friday so the continuous vacation is only 5 days (May 1st to May 5th). And the May Day in 2016 is Sunday so the continuous vacation is 6 days (April 30th to May 5th). In 2017, the May Day is Monday so the vacation is 9 days (April 29th to May 7th). How excited!
Edward, the headmaster of Marjar University, is very curious how long is the continuous vacation containing May Day in different years. Can you help him?
There are multiple test cases. The first line of input contains an integer Tindicating the number of test cases. For each test case, there is an integer y (1928 <= y <= 9999) in one line, indicating the year of Edward's query.
For each case, print the number of days of the continuous vacation in that year.
3 2015 2016 2017
5 69
题意:输一个N,n是输入数据的个数,随后再输入n个数据,每个数据是年份,求这个年份中,五一劳动节这一天能放几天假、
分析:第一步先求出5.1这一天是星期几,这里是要判读闰年的,然后直接上公式,ps:公式是网上搜的。
第二部:根据所得的星期几,把它放到一个一维数组中,里面有7个数据,每个数据都是固定的,因为星期几对应几天假期是固定的。
公式:第一种:
—— 蔡勒(Zeller)公式 历史上的某一天是星期几?未来的某一天是星期几?关于这个问题,有很多计算公式(两个通用计算公式和一些分段计算公式),其中最著名的是蔡勒(Zeller)公式.即w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1 公式中的符号含义如下,w:星期;c:世纪-1;y:年(两位数);m:月(m大于等于3,小于等于14,即在蔡勒公式中,某年的1、2月要看作上一年的13、14月来计算,比如2003年1月1日要看作2002年的13月1日来计算);d:日;[ ]代表取整,即只要整数部分.(C是世纪数减一,y是年份后两位,M是月份,d是日数.1月和2月要按上一年的13月和 14月来算,这时C和y均按上一年取值.) 算出来的W除以7,余数是几就是星期几.如果余数是0,则为星期日. 以2049年10月1日(100周年国庆)为例,用蔡勒(Zeller)公式进行计算, 蔡勒(Zeller)公式:w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1 =49+[49/4]+[20/4]-2×20+[26× (10+1)/10]+1-1 =49+[12.25]+5-40+[28.6] =49+12+5-40+28 =54 (除以7余5) 即2049年10月1日(100周年国庆)是星期5.
----------------------------------------------这个公式最后代码没有采用是因为最后测试数据的时候w出来个负值,这杨肯定不行。
第二种:s=x-1+[(x-1)/4]-[(x-1)/100]+[(x-1)/400]+y
s是星期几,不过要先除以7取余,没有余数是星期天,余数是1.2是星期1,2……
y是这一天是这一年的第几天,
x是年份