Hdoj 1201-18 Birthday

Source: Internet
Author: User

"Idea": it takes 18 years anyway, so the question is whether the 18 is a leap year. Note: Judging after February from the beginning of the next year 18, before February judged 18 years starting from this year. There is also a special award for the 29 birthday of February. Ps. One year is 365 days, not 356 days!

"AC Code":

#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include < Algorithm> #include <iomanip>using namespace std;int isleapyear (int y) {    if (y%4==0&&y%100!=0) | | (y%400==0))        return 1;    return 0;} int main () {    int T = 0;    Cin >> T;    while (t--)    {        int year = 0, month = 0, day = 0;        int i = 0, days = 0;        char c;        CIN >> Year >> C >> month >> C >> Day;        if (2 = = Month && = = Day && 0 = isleapyear (year+18))        {            cout <<-1 << endl;            Continue;        }        if (Month > 2) year            + = 1;        for (i = 0; i <, i++)        {            if (isleapyear (year+i)) days                + = 366;            else days                + = 365;        }        cout << days << endl;    }    return 0;}


Hdoj 1201-18 Birthday

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.