题目大意:

应该是给你一个日子,某年某月某日,问你在这之后的最近的哪一年的这一天和给你的日子的星期数一样。

代码:

#include<bits/stdc++.h>
using namespace std;

int test=0;
int year0,month0,day0;
char a[25]={0};

int f(int year,int month,int day)
{
    int flag=0;
    if(year%400==0||(year%4==0&&year%100!=0))flag=1;
    if(flag==0&&month==2&&day==29)return -1;
    if(month==1||month==2)//判断month是否为1或2 
    {
        year--;
        month+=12;
    }
    int c=year/100;
    int y=year-c*100;
    int week=(c/4)-2*c+(y+y/4)+(13*(month+1)/5)+day-1;
    while(week<0){week+=7;}
    week%=7;
    return week;
}

int main()
{
    scanf("%d",&test);
    while(test--)
    {
        scanf("%s",a);
        year0= (a[0]-'0')*1000 + (a[1]-'0')*100 + (a[2]-'0')*10 + (a[3]-'0');
        month0= (a[5]-'0')*10 + a[6]-'0';
        day0= (a[8]-'0')*10 + a[9]-'0';
        /*scanf("%d-%d-%d",&year0,&month0,&day0);*/
        int t=f(year0,month0,day0);
        while(year0++)
        {
            if(f(year0,month0,day0)==t)
            {
                printf("%d\n",year0);
                break;
            }
        }
    }
}