思路:水题...
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int a[10010];
void init(){
a[2016] = 6;
for(int i=2017;i<10010;++i){
if((i%400==0||i%100!=0)&&i%4==0){
a[i] = (a[i-1]+2)%7;
}
else a[i] = (a[i-1]+1)%7;
}
for(int i=2015;i>=1810;--i){
if(((i+1)%400==0||(i+1)%100!=0)&&(i+1)%4==0){
a[i] = (a[i+1]-2+7)%7;
}
else a[i] = (a[i+1]-1+7)%7;
}
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int ca;
init();
scanf("%d", &ca);
while(ca--){
int n;
scanf("%d", &n);
// cout<<"a[n]:"<<a[n]<<endl;
if(a[n]==0) puts("9");
else if(a[n]==6) puts("6");
else if(a[n]==1) puts("6");
else puts("5");
}
return 0;
}