I ask year (analog date) __ Thinking

Source: Internet
Author: User
I ask Ho XI
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 568 accepted Submission (s): 168
Problem Description
Today is August 6, 2017, the lunar calendar June 15. Small degree alone railing, looking at a round moon, issued a "I ask Xi, see this Lover" lonely feeling. To divert the knot, it decided to think about a mathematical problem: the same day of the next recent year, and the number of weeks today. For example, today is August 6, Sunday. The next is also Sunday, August 6, which took place in 2023. Tip: In the Gregorian calendar, a leap year can be divisible by 4 but not divisible by 100, or divisible by 400.
Input
The first behavior, T, represents the number of input data sets. Each group of data contains a date, formatted as YYYY-MM-DD. 1≤t≤10000 yyyy≥2017 Date must be a valid date Output
For each set of data output answer year, the title guarantee that the answer will not exceed four digits.
Sample Input
3
2017-08-06
2017-08-07
2018-01-01
Sample Output
2023
2023
2024
#include <queue> #include <map> #include <vector> #include <cmath> #include <stack> #

Include <climits> #include <string> #include <cstring> #include <algorithm> using namespace std;
int t[10003][13][35];
int yue[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    int main () {int num = 1;
    int year = 1,m = 1,n = 1;
    memset (t,-1,sizeof (T)); while (!) (
            Year = = 10000 && m = = 1 && n = 1)) {if (year%4==0 && year%100!=0 | |-year%400 = 0)
        YUE[2] = 29;
        else yue[2] = 28;
        T[year][m][n] = num++;
        Int j = N/yue[m];
        n++;
            if (j) {n = 1;
            j = (m)/12;
            m++;
            if (j) m = 1;
        Year + + J;
    } int t;
    scanf ("%d", &t);
        while (t--) {scanf ("%d-%d-%d", &year,&m,&n);
        int be = T[year][m][n]; for (int i = Year+1;i < 10000; i++) {if (T[i][m][n]!=-1 && (t[i][m][n]-be)% 7 = 0) {printf (
                "%d\n", I);
            Break
}} return 0;
 }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.