May Day Holiday

Time Limit: 2 Seconds Memory Limit: 65536 KB

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?

Input

There are multiple test cases. The first line of input contains an integer T indicating 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.

Output

For each case, print the number of days of the continuous vacation in that year.

Sample Input

3

2015

2016

2017

Output

5

6

9

#include <iostream>
#include <string>
#include <stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<stack>
#include<queue> using namespace std; const int MAX=10000+10; int day[MAX]; int main()
{ day[0]=0; for(int i=1;i<MAX;i++)
{
if((i%4==0&&i%100!=0)||(i%400==0))
{
day[i]=day[i-1]+366;
}
else
{
day[i]=day[i-1]+365;
} } int T,year; scanf("%d",&T); while(T--)
{
scanf("%d",&year); int d=day[year-1]; if((year%4==0&&year%100!=0)||(year%400==0))
{
d+=121;
}
else
{
d+=120;
} d++; int s=d%7; if(s==1)
{
cout<<9<<endl;
}
else if(s==0||s==2)
{
cout<<6<<endl;
}
else
{
cout<<5<<endl;
}
} return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

第十二届浙江省大学生程序设计大赛-May Day Holiday 分类: 比赛 2015-06-26 14:33 10人阅读 评论(0) 收藏的更多相关文章

  1. 第十二届浙江省大学生程序设计大赛-Capture the Flag 分类: 比赛 2015-06-26 14:35 10人阅读 评论(0) 收藏

    Capture the Flag Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge In computer security, Ca ...

  2. 第十二届浙江省大学生程序设计大赛-Beauty of Array 分类: 比赛 2015-06-26 14:27 12人阅读 评论(0) 收藏

    Beauty of Array Time Limit: 2 Seconds Memory Limit: 65536 KB Edward has an array A with N integers. ...

  3. 第十二届浙江省大学生程序设计大赛-Ace of Aces 分类: 比赛 2015-06-26 14:25 12人阅读 评论(0) 收藏

    Ace of Aces Time Limit: 2 Seconds Memory Limit: 65536 KB There is a mysterious organization called T ...

  4. 第十二届浙江省大学生程序设计大赛-Demacia of the Ancients 分类: 比赛 2015-06-26 14:39 30人阅读 评论(0) 收藏

    Demacia of the Ancients Time Limit: 2 Seconds Memory Limit: 65536 KB There is a popular multiplayer ...

  5. 第十二届浙江省大学生程序设计大赛-Lunch Time 分类: 比赛 2015-06-26 14:30 5人阅读 评论(0) 收藏

    Lunch Time Time Limit: 2 Seconds Memory Limit: 65536 KB The 999th Zhejiang Provincial Collegiate Pro ...

  6. 第十二届浙江省大学生程序设计大赛-Team Formation 分类: 比赛 2015-06-26 14:22 50人阅读 评论(0) 收藏

    Team Formation Time Limit: 3 Seconds Memory Limit: 131072 KB For an upcoming programming contest, Ed ...

  7. 团体程序设计天梯赛L3-010 是否完全二叉搜索树 2017-03-24 16:12 29人阅读 评论(0) 收藏

    L3-010. 是否完全二叉搜索树 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 将一系列给定数字顺序插入一个初始为空的二叉搜 ...

  8. Android 应用中十大常见 UX 错误 分类: H1_ANDROID 2013-09-21 13:59 404人阅读 评论(0) 收藏

    转载自:http://www.apkbus.com/android-5661-1.html 摘要: Android 开发者关系团队每天都会试用无数的 App 或者受到无数的开发者发来的请求评测的 Ap ...

  9. 2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛--n a^o7 ! 分类: 比赛 2015-06-09 17:16 14人阅读 评论(0) 收藏

    n a^o7 ! Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 All brave and intelligent fighte ...

随机推荐

  1. ClassLoader,Thread.currentThread().setContextClassLoader,tomcat的ClassLoader

    实际上,在Java应用中所有程序都运行在线程里,如果在程序中没有手工设置过ClassLoader,对于一般的java类如下两种方法获得的ClassLoader通常都是同一个 this.getClass ...

  2. ArrayList和LinkList区别

    ArrayList和LinkList区别 前者是数组的数据结构,后者是链表的数据结构 前者应用于排序和查找,后者应用于插入删除

  3. 分享Centos作为WEB服务器的防火墙规则

    # Firewall configuration written by system-config-firewall # Manual customization of this file is no ...

  4. struts局部、全局类型转换器

    第01步:编写bean package com.self.bean; import java.util.Date; public class User { private Date birthday ...

  5. paper 73 :HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像

    HDR(High Dynamic Range Imaging)在摄影中指高动态范围成像.国内的教程基本语焉不详,找到一篇比较详尽的国外教程翻译出来,希望对大家有帮助.^_^ 原文地址:http://p ...

  6. paper 24 :matlab的cat函数

    cat:用来联结数组 用法:C = cat(dim, A, B)       按dim来联结A和B两个数组. C = cat(dim, A1, A2, A3, ...)    按dim联结所有输入的数 ...

  7. oracle文件版本

    strings -a  $AU_TOP/forms/US/GLXFCRVL.fmb|grep '$Header' 比如 strings -a /u02/CRP2/apps/apps_st/appl/a ...

  8. 夺命雷公狗---node.js---7fs模块初步

    目录结构如下所示: /** * Created by leigood on 2016/8/13. */ var http = require("http"); var fs = r ...

  9. bootstrap, boosting, bagging 几种方法的联系

    http://blog.csdn.net/jlei_apple/article/details/8168856 这两天在看关于boosting算法时,看到一篇不错的文章讲bootstrap, jack ...

  10. ASP.NET MVC (一)

    工作清闲好一段时间了,趁这段时间弄了弄PHP,做个了简单的MVC网页.玩了玩Android,弄了个拨号器,发短信的,嘿嘿,最满意的还是两天弄了个数独游戏.不务正业一个多月了,也该磨磨刀,接下来一段时间 ...