12439 - February 29

All about problems in Volume 124. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

12439 - February 29

Post by brianfry713 » Tue Feb 28, 2012 9:07 am

Here's some input:

Code: Select all

7
January 12, 2012
March 19, 2012
August 12, 2899
August 12, 2901
August 12, 2000
August 12, 2005
February 29, 2004
February 29, 2012
January 1, 2012
February 28, 2012
February 28, 2012
March 1, 2012
January 1, 2000
December 31, 2000000000
AC output:

Code: Select all

Case 1: 1
Case 2: 0
Case 3: 1
Case 4: 3
Case 5: 0
Case 6: 1
Case 7: 484999516
Check input and AC output for thousands of problems on uDebug!

sayedirfan CU
New poster
Posts: 1
Joined: Thu Mar 01, 2012 12:29 pm

Re: 12439 - February 29

Post by sayedirfan CU » Thu Mar 01, 2012 12:46 pm

Guys you should also try this test cases..

Input :

Code: Select all

16
January 12, 2012
March 19, 2012
August 12, 2899
August 12, 2901
August 12, 2000
August 12, 2005
February 29, 2004
February 29, 2012
January 1, 2000
February 28, 2000
January 1, 1999
February 29, 2000
September 1, 2000
September 2, 2000
February 28, 2000
February 29, 2004
March 1, 2000
February 28, 2004
January 1, 2000
January 1, 2004
February 28, 2000
February 29, 2000
March 1, 2001
April 1, 2004
February 29, 2000
February 29, 2000
January 1, 2996
March 1, 3004
January 1, 2000
January 1, 2000000000
January 1, 2000
February 29, 2000000000
Output :

Code: Select all

Case 1: 1
Case 2: 0
Case 3: 1
Case 4: 3
Case 5: 0
Case 6: 1
Case 7: 0
Case 8: 2
Case 9: 0
Case 10: 1
Case 11: 1
Case 12: 1
Case 13: 1
Case 14: 2
Case 15: 484999515
Case 16: 484999516
Will be glad if it helps you..

Angry Bird
New poster
Posts: 21
Joined: Mon Apr 08, 2013 8:38 am

Re: 12439 - February 29

Post by Angry Bird » Wed Dec 18, 2013 4:19 am

Getting Time Limit. Please check it. :evil:

Code: Select all

#include <bits/stdc++.h>

using namespace std;

int main()
{
    map<string,int>m;
    m["January"]=1;
    m["February"]=2;
    m["March"]=3;
    m["April"]=4;
    m["May"]=5;
    m["June"]=6;
    m["July"]=7;
    m["August"]=8;
    m["September"]=9;
    m["October"]=10;
    m["November"]=11;
    m["December"]=12;

    int year1,year2,t,day1,day2;
    scanf("%d",&t);
    getchar();

    char month1[100],month2[100];
    int i;
    for(i=1; i<=t; i++)
    {
        scanf("%s %d, %d\n",&month1,&day1,&year1);
        scanf("%s %d, %d",&month2,&day2,&year2);

        int c=0;
        if((m.find(month1)->second)>2)
            year1++;
        if((m.find(month2)->second)<2)
            year2--;
        else if(((m.find(month2)->second)==2) and (day2<29))
           year2--;


        for(int j=year1; j<=year2; )
        {
            if(((j%4==0)&&(j%100!=0))||(j%400==0))
            {
                c++;
                j=j+4;
            }
            else
            {
                j++;
            }
        }

        printf("Case %d: %d\n",i,c);
    }
    return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12439 - February 29

Post by brianfry713 » Fri Dec 20, 2013 9:26 pm

You'll need to do some math rather than iterate from the first to the second year.
Check input and AC output for thousands of problems on uDebug!

cse dipto
New poster
Posts: 22
Joined: Tue Oct 29, 2013 6:46 pm

Re: 12439 - February 29 pls help me get so much WA

Post by cse dipto » Fri Jan 31, 2014 3:35 pm

Code: Select all

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stack>
#include <queue>
#include <map>
#include <vector>


using namespace std;

int main()
{
    long long int i,j,k,t_case,d1,y,y2,d2,count1,count2,lpyr,r2,len,sum,len2,sum2,ans,lp;
    long long int temp;
    double r3,r;
    string m,m2,M,M2;
    char s[10000],d[10000];
    scanf("%lld",&t_case);
    for(i=1;i<=t_case;i++)
    {
        count1=0;
        count2=0;
        lp=0;
        r=0;
        r2=0;
        r3=0;
        ans=0;
        cin>>m;
        scanf("%lld,",&d1);
        scanf("%lld",&y);
        cin>>m2;
        scanf("%lld,",&d2);
        scanf("%lld",&y2);
        r=y2-y;

        if(r<=1000)
        {
            for(j=y;j<=y2;j++)
            {
                temp=j;
                if(temp%400==0||temp%4==0&&temp%100!=0)
                {
                    lp++;
                }
            }
        }

        else
        {
            if(y%400==0||y%4==0&&y%100!=0)
            {
                lp++;
            }
            if(y2%400==0||y2%4==0&&y2%100!=0)
            {
                lp++;
            }
            if(lp==2)
            {
                lp--;
            }
            r3=((r/50)*12.125);
            r2=r3;
            lp=lp+r2;
        }

        if(y%400==0||y%4==0&&y%100!=0)
        {
            if(m=="January"||m=="February")
            {
                ans=lp;
            }
            else
            {
                lp--;
            }
        }
        if(y2%400==0||y2%4==0&&y2%100!=0)
        {
            if(m2=="January")
            {
                lp--;
            }
            if(m2=="February"&&d2<29)
            {
                lp--;
            }
        }
        printf("Case %lld: %lld\n",i,lp);
    }
    return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12439 - February 29

Post by brianfry713 » Fri Jan 31, 2014 9:23 pm

Try solving it without using floating point.
Check input and AC output for thousands of problems on uDebug!

sadee
New poster
Posts: 3
Joined: Sat Mar 08, 2014 9:19 am

Why WA 12439 - February 29??? pls help

Post by sadee » Sat Mar 22, 2014 1:40 pm

pls dont laugh to see my code.
i m new in programming.....

Code: Select all

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

char m1[15],m2[15];

long long int clp(long long int x,long long int y)
{
    int count=0,m;

   if((y-x)<=100)
   {
       for(int i=x;i<=y;i+=4)
       {
           if((i%400!=0)&&(i%4==0&&i%100==0))
           {
               count++;
           }
       }
       return count;
   }
    else if((y-x)>=2000)
    {
        for(int i=4000; i<=y; i+=2000)
        {
            count+=15;
            m=y-i;
        }
        if(m!=0)
            return (count+(8/1000)*m);
        else return count;
    }
    else return ((8/1000)*(y-x));

}
long long int clp1(long long int y)
{
    while(1)
    {
        if((y%400==0)||(y%4==0&&y%100!=0))break;
        y++;
    }
    return y;
}
long long int clp2(long long int x)
{
    while(1)
    {
        if((x%400==0)||(x%4==0&&x%100!=0))break;
        x--;
    }
    return x;
}

int main()
{
    long long int tcase=0,cases,i,j,d1,d2,y1,y2;
    cin>>cases;
    while(cases--)
    {
        int count=0;
        scanf("%s %lld, %lld",m1,&d1,&y1);
        scanf("%s %lld, %lld",m2,&d2,&y2);
        if(clp1(y1)>y2) printf("Case %lld: 0\n",++tcase);
        else if(y1==y2&&y1==clp1(y1)&&y2==clp2(y2))
        {
            if(strcmp(m1,"January")==0||strcmp(m1,"February")==0)
            {
                if(((strcmp(m2,"January")!=0&&strcmp(m2,"February")!=0))||(strcmp(m2,"February")==0&&d2==29))
                {
                    printf("Case %lld: %lld\n",++tcase,((y2-y1)/4)+1);
                }
                else if(strcmp(m2,"January")==0||strcmp(m2,"February")==0) printf("Case %lld: %lld\n",++tcase,((clp2(y2)-y1)/4));
                else printf("Case %lld: %lld\n",++tcase,((clp2(y2)-clp1(y1))/4)+1);
            }
            else if(strcmp(m1,"January")!=0||strcmp(m1,"February")!=0)
            {
                if(strcmp(m2,"February")==0&&d2==29)
                {
                    printf("Case %lld: %lld\n",++tcase,((y2-y1)/4)+1);
                }
                else if(strcmp(m2,"January")==0||strcmp(m2,"February")==0) printf("Case %lld: %lld\n",++tcase,((clp2(y2)-y1)/4));
                else printf("Case %lld: %lld\n",++tcase,(clp2(y2)-clp1(y1))/4);
            }
        }
        else if(y1<clp1(y1)&&clp2(y2)<y2)
        {
            printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)+1)-clp(y1,y2));
        }
        else if(y1<clp1(y1)&&clp2(y2)==y2)
        {
            if(((strcmp(m2,"January")!=0&&strcmp(m2,"February")!=0))||(strcmp(m2,"February")==0&&d2==29))
            {
                printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)+1)-clp(y1,y2));
            }
            else  printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)-clp(y1,y2)));
        }
        else if(y1==clp1(y1)&&y2>clp2(y2))
        {
            if(strcmp(m1,"January")==0||strcmp(m1,"February")==0)
            {
                printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)+1)-clp(y1,y2));
            }
            else if(strcmp(m1,"January")!=0||strcmp(m1,"February")!=0)
            {
                printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)-clp(y1,y2)));
            }
        }
        else if(y1==clp1(y1)&&y2==clp2(y2))
        {
            if(strcmp(m1,"January")==0||strcmp(m1,"February")==0)
            {
                if(((strcmp(m2,"January")!=0&&strcmp(m2,"February")!=0))||(strcmp(m2,"February")==0&&d2==29))
                {
                    printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)+1)-clp(y1,y2));
                }
                else if(strcmp(m2,"January")==0||strcmp(m2,"February")==0) printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)-clp(y1,y2)));
                else printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)+1)-clp(y1,y2));
            }
            else if(strcmp(m1,"January")!=0||strcmp(m1,"February")!=0)
            {
                if(strcmp(m2,"February")==0&&d2==29)
                {
                    printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)+1)-clp(y1,y2));
                }
                else if(strcmp(m2,"January")==0||strcmp(m2,"February")==0) printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)-clp(y1,y2))-1);
                else printf("Case %lld: %lld\n",++tcase,(((clp2(y2)-clp1(y1))/4)-clp(y1,y2)));
            }
        }
    }
    return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: Why WA 12439 - February 29??? pls help

Post by brianfry713 » Tue Mar 25, 2014 1:21 am

Input:

Code: Select all

500
November 27, 2068
February 26, 2074
May 22, 2054
September 12, 2058
June 5, 2063
August 30, 2065
February 25, 2049
February 6, 2052
December 22, 2054
September 14, 2063
June 18, 2096
June 23, 2104
August 11, 2083
August 20, 2086
May 16, 2023
July 8, 2028
February 16, 2015
May 23, 2020
December 10, 2016
August 23, 2021
October 28, 2010
January 18, 2019
March 20, 2014
October 16, 2016
June 13, 2068
September 2, 2074
May 16, 2075
January 14, 2082
May 26, 2010
October 19, 2011
November 12, 2002
April 5, 2011
March 4, 2024
July 14, 2029
September 2, 2085
July 2, 2086
May 7, 2095
April 17, 2103
December 11, 2062
July 3, 2071
December 7, 2063
February 23, 2069
April 26, 2006
January 9, 2007
February 26, 2088
June 21, 2089
May 21, 2061
September 1, 2070
November 22, 2099
February 7, 2106
February 9, 2029
November 16, 2038
July 13, 2036
February 16, 2044
November 30, 2044
March 13, 2052
April 7, 2058
May 21, 2063
November 14, 2057
December 14, 2064
May 2, 2076
June 24, 2077
August 8, 2022
February 7, 2025
May 5, 2019
March 3, 2027
August 20, 2080
April 14, 2088
September 24, 2029
April 17, 2032
December 14, 2077
February 27, 2078
July 26, 2086
June 28, 2090
September 14, 2032
May 31, 2035
July 26, 2009
May 14, 2012
January 19, 2072
January 30, 2076
July 8, 2010
March 15, 2018
February 25, 2040
November 5, 2047
March 16, 2039
April 5, 2046
September 14, 2076
October 20, 2084
March 2, 2005
February 14, 2014
January 6, 2052
July 18, 2053
April 30, 2074
February 20, 2076
October 4, 2080
May 12, 2083
August 24, 2024
June 10, 2031
December 6, 2014
May 9, 2016
September 12, 2008
July 28, 2014
July 30, 2020
October 15, 2024
July 11, 2012
June 15, 2018
February 15, 2096
May 2, 2104
January 11, 2054
July 19, 2054
June 16, 2070
May 23, 2073
March 2, 2037
March 6, 2038
August 6, 2031
September 2, 2033
April 28, 2053
October 23, 2062
August 9, 2082
March 7, 2085
February 26, 2090
December 31, 2096
December 4, 2091
November 19, 2093
November 1, 2055
November 12, 2060
March 14, 2043
July 23, 2048
July 8, 2093
May 26, 2097
June 27, 2026
September 11, 2028
May 12, 2098
July 9, 2105
January 16, 2068
March 19, 2068
October 16, 2071
February 16, 2079
August 13, 2012
April 20, 2014
October 31, 2015
September 18, 2022
February 6, 2054
July 28, 2059
August 1, 2035
April 2, 2040
August 19, 2011
September 9, 2020
November 27, 2011
March 8, 2018
June 19, 2039
May 21, 2043
March 24, 2062
April 22, 2065
June 16, 2005
January 14, 2011
May 27, 2074
October 15, 2080
August 22, 2053
December 7, 2054
April 26, 2060
February 5, 2062
August 19, 2060
March 28, 2067
February 15, 2085
March 24, 2088
August 7, 2059
January 19, 2061
December 29, 2085
September 11, 2086
February 22, 2052
December 13, 2052
November 18, 2012
July 13, 2019
May 17, 2075
July 12, 2077
August 22, 2049
October 21, 2053
May 6, 2083
April 27, 2086
April 7, 2031
August 4, 2033
May 7, 2018
June 8, 2026
January 27, 2016
May 18, 2019
June 1, 2036
May 21, 2039
May 2, 2069
February 23, 2072
April 26, 2046
June 25, 2055
April 26, 2072
June 15, 2077
January 21, 2085
October 20, 2094
November 1, 2077
October 8, 2084
June 9, 2066
December 5, 2069
November 1, 2047
November 16, 2052
August 12, 2048
April 9, 2050
June 20, 2040
May 5, 2048
February 27, 2093
August 15, 2100
October 13, 2044
June 6, 2045
January 9, 2074
January 14, 2077
February 2, 2057
May 23, 2063
June 15, 2081
November 2, 2084
July 18, 2002
January 3, 2011
February 18, 2067
September 5, 2070
February 24, 2002
November 26, 2007
October 21, 2031
October 18, 2037
January 22, 2015
December 19, 2018
March 28, 2057
December 5, 2063
November 21, 2059
May 10, 2060
September 4, 2036
June 1, 2038
September 30, 2052
May 28, 2060
September 15, 2037
May 6, 2046
October 9, 2008
July 31, 2011
January 12, 2047
June 19, 2055
August 7, 2030
November 27, 2036
September 7, 2021
June 18, 2024
May 2, 2097
November 2, 2100
November 19, 2091
February 14, 2093
August 1, 2065
October 10, 2071
August 11, 2062
June 16, 2071
July 24, 2019
April 25, 2020
January 23, 2012
May 22, 2019
August 25, 2071
March 5, 2074
May 25, 2035
August 26, 2036
June 13, 2048
January 26, 2055
July 29, 2031
February 27, 2032
May 19, 2012
January 13, 2017
June 25, 2016
November 8, 2024
October 13, 2001
September 13, 2008
April 24, 2045
February 3, 2046
January 17, 2024
October 15, 2030
July 7, 2005
October 29, 2005
April 10, 2099
January 31, 2102
January 8, 2029
March 30, 2031
March 6, 2024
May 10, 2028
March 29, 2046
August 13, 2055
April 20, 2073
December 22, 2077
October 5, 2044
December 8, 2044
October 11, 2016
February 5, 2017
January 27, 2032
November 14, 2038
March 21, 2054
June 23, 2060
September 15, 2006
June 9, 2013
March 8, 2052
February 16, 2053
May 27, 2012
February 9, 2013
September 5, 2061
February 25, 2063
November 17, 2062
September 17, 2071
August 12, 2000
October 4, 2002
January 9, 2027
October 2, 2028
November 29, 2008
February 15, 2017
March 26, 2089
October 22, 2098
June 21, 2029
August 22, 2031
April 2, 2007
November 18, 2009
July 7, 2096
May 20, 2104
May 6, 2067
June 3, 2073
April 7, 2070
April 28, 2074
May 31, 2003
July 6, 2008
March 23, 2027
July 12, 2027
March 18, 2092
July 12, 2099
July 16, 2004
January 1, 2007
March 1, 2038
September 15, 2039
July 4, 2040
November 15, 2042
February 14, 2004
December 31, 2011
June 17, 2086
April 21, 2092
September 15, 2060
January 10, 2069
January 2, 2086
July 21, 2091
February 2, 2018
February 6, 2027
March 28, 2021
May 31, 2021
October 5, 2003
February 2, 2007
January 23, 2043
December 3, 2052
July 5, 2033
October 4, 2037
March 25, 2075
January 8, 2076
May 31, 2001
August 20, 2001
October 22, 2049
March 23, 2053
May 3, 2052
January 13, 2054
April 8, 2029
January 27, 2037
December 12, 2011
June 25, 2013
November 29, 2092
September 27, 2100
November 24, 2006
April 2, 2013
August 20, 2068
October 18, 2075
March 7, 2013
January 21, 2020
September 6, 2032
September 18, 2040
April 19, 2020
November 14, 2028
September 5, 2094
October 9, 2100
December 23, 2018
November 4, 2022
October 5, 2022
June 19, 2023
August 30, 2026
November 25, 2032
November 23, 2033
June 4, 2037
October 11, 2016
February 26, 2024
May 4, 2016
November 9, 2016
October 26, 2004
February 11, 2012
June 3, 2066
September 20, 2073
July 29, 2008
November 30, 2012
September 18, 2074
January 17, 2083
June 28, 2060
November 19, 2067
April 18, 2014
May 12, 2019
December 11, 2008
February 27, 2013
November 15, 2003
February 28, 2009
April 15, 2085
February 3, 2093
April 25, 2017
March 10, 2021
May 1, 2054
October 15, 2062
February 14, 2059
December 3, 2068
October 11, 2053
April 30, 2059
April 18, 2018
October 17, 2024
August 26, 2015
December 13, 2019
March 20, 2026
March 3, 2031
February 10, 2058
May 26, 2058
November 2, 2085
September 20, 2090
November 26, 2065
September 25, 2071
October 13, 2036
April 21, 2039
March 20, 2020
February 24, 2026
February 26, 2051
June 5, 2058
February 27, 2069
August 18, 2075
December 5, 2008
November 7, 2015
May 18, 2079
January 31, 2087
March 16, 2052
July 19, 2052
July 11, 2001
November 5, 2008
July 20, 2016
March 25, 2025
September 16, 2052
August 4, 2053
October 30, 2082
March 29, 2088
September 7, 2054
September 25, 2055
April 21, 2097
May 14, 2106
February 4, 2056
November 28, 2062
May 28, 2019
November 3, 2027
June 14, 2028
March 26, 2032
November 16, 2088
February 25, 2095
December 3, 2030
July 6, 2036
March 8, 2078
October 2, 2083
January 5, 2068
January 2, 2072
January 20, 2053
July 11, 2062
October 26, 2084
August 21, 2088
September 21, 2067
April 2, 2075
July 1, 2024
July 17, 2033
January 31, 2023
December 4, 2031
March 10, 2079
January 8, 2085
December 15, 2098
August 1, 2107
September 15, 2083
December 18, 2084
September 19, 2008
July 21, 2016
January 31, 2060
May 24, 2064
April 10, 2077
December 5, 2080
February 3, 2038
June 28, 2047
September 9, 2033
November 16, 2034
February 12, 2017
October 16, 2026
November 8, 2035
April 24, 2042
January 29, 2079
July 29, 2083
January 1, 2032
October 5, 2032
August 30, 2064
February 10, 2068
April 15, 2003
January 26, 2010
June 10, 2035
August 9, 2037
February 1, 2022
September 22, 2028
April 8, 2065
November 19, 2073
February 13, 2019
September 4, 2020
July 22, 2018
February 20, 2019
April 5, 2001
March 12, 2010
November 22, 2059
June 3, 2067
January 25, 2052
April 12, 2060
August 25, 2021
April 26, 2022
March 24, 2024
April 21, 2029
July 19, 2034
February 13, 2038
October 16, 2043
November 19, 2045
January 17, 2044
October 22, 2053
January 27, 2070
February 13, 2076
December 9, 2091
July 16, 2100
April 21, 2032
October 23, 2040
October 21, 2081
December 9, 2085
August 27, 2087
January 27, 2095
April 9, 2039
September 6, 2040
January 16, 2009
September 19, 2010
May 26, 2041
October 30, 2045
August 9, 2033
November 25, 2038
June 17, 2069
May 26, 2076
December 6, 2039
April 24, 2044
March 7, 2002
November 17, 2004
April 8, 2086
July 24, 2092
April 18, 2074
December 7, 2081
November 14, 2073
January 20, 2079
July 7, 2059
June 18, 2064
June 26, 2082
February 1, 2083
October 28, 2068
December 23, 2071
July 27, 2019
October 11, 2028
August 17, 2091
March 16, 2097
January 31, 2021
November 1, 2025
May 28, 2018
March 7, 2023
October 9, 2024
June 2, 2025
August 22, 2021
December 15, 2022
February 9, 2015
August 30, 2023
August 19, 2052
January 20, 2059
February 16, 2046
March 13, 2051
December 2, 2028
June 18, 2031
August 27, 2028
April 17, 2037
January 16, 2002
August 15, 2004
July 23, 2096
August 21, 2103
July 10, 2002
February 24, 2011
May 7, 2054
June 24, 2058
November 28, 2071
May 4, 2079
October 24, 2061
August 24, 2066
August 28, 2037
June 17, 2044
October 18, 2052
March 10, 2061
July 2, 2013
November 15, 2015
May 25, 2043
June 24, 2044
March 14, 2087
May 11, 2089
August 2, 2025
January 24, 2030
April 20, 2061
July 26, 2061
February 5, 2038
May 30, 2040
June 12, 2020
May 19, 2028
June 11, 2087
October 1, 2095
November 21, 2065
May 12, 2070
April 10, 2036
April 17, 2037
December 24, 2022
April 14, 2031
August 24, 2085
July 5, 2090
June 18, 2018
December 19, 2018
December 21, 2008
April 6, 2012
May 2, 2036
April 19, 2038
February 11, 2020
December 23, 2025
September 13, 2006
March 12, 2008
July 18, 2050
February 20, 2056
October 23, 2047
April 12, 2051
September 15, 2068
October 25, 2069
January 23, 2047
August 19, 2054
May 10, 2094
January 22, 2097
May 22, 2090
January 11, 2092
May 5, 2037
March 28, 2043
October 29, 2011
August 21, 2017
April 27, 2006
July 13, 2015
December 21, 2062
July 10, 2064
October 16, 2052
June 19, 2055
March 23, 2077
October 2, 2079
November 13, 2023
September 24, 2027
May 18, 2002
February 20, 2010
December 16, 2034
December 11, 2037
July 17, 2055
October 26, 2062
January 23, 2017
December 25, 2022
July 10, 2005
February 1, 2009
June 1, 2012
May 2, 2013
November 4, 2028
August 12, 2034
December 20, 2061
December 11, 2069
July 10, 2017
June 3, 2018
September 6, 2039
October 13, 2044
May 12, 2081
July 1, 2090
November 13, 2006
September 26, 2015
December 1, 2015
November 30, 2018
January 19, 2064
November 23, 2068
July 23, 2086
March 9, 2088
January 7, 2000
September 27, 2008
August 15, 2085
August 4, 2094
February 12, 2035
July 29, 2041
January 28, 2063
April 18, 2064
October 8, 2058
January 30, 2062
October 5, 2035
April 23, 2037
October 5, 2029
June 5, 2035
December 6, 2037
July 28, 2039
June 5, 2073
June 19, 2081
November 11, 2025
July 31, 2027
December 6, 2035
May 11, 2042
January 31, 2063
July 21, 2069
November 12, 2028
February 15, 2029
May 17, 2032
March 20, 2038
December 30, 2035
December 27, 2044
October 21, 2045
January 12, 2054
May 5, 2066
November 18, 2068
November 1, 2096
November 22, 2105
June 14, 2056
September 7, 2060
October 15, 2030
June 2, 2038
January 18, 2008
July 6, 2009
February 4, 2030
August 12, 2033
July 25, 2094
September 6, 2095
April 6, 2088
October 15, 2095
October 15, 2055
June 19, 2062
October 16, 2094
July 22, 2101
February 13, 2003
September 18, 2012
September 20, 2028
November 23, 2030
August 18, 2037
February 26, 2046
September 10, 2071
May 20, 2077
July 27, 2015
January 2, 2018
March 10, 2005
July 17, 2008
October 1, 2075
May 5, 2084
August 21, 2002
February 13, 2011
January 10, 2074
December 19, 2076
May 25, 2080
July 7, 2085
November 28, 2019
October 14, 2020
February 23, 2084
July 10, 2089
November 16, 2035
September 11, 2040
November 7, 2027
March 31, 2034
August 4, 2022
January 17, 2023
August 1, 2027
September 12, 2033
January 11, 2025
December 20, 2028
February 12, 2041
April 11, 2044
November 15, 2065
April 5, 2067
December 26, 2086
June 6, 2094
February 11, 2022
June 12, 2025
March 14, 2036
January 2, 2045
February 16, 2070
April 22, 2077
August 24, 2006
January 8, 2014
November 7, 2080
December 24, 2084
December 31, 2089
September 14, 2092
June 14, 2038
September 25, 2044
January 24, 2037
September 13, 2046
December 1, 2056
April 28, 2061
June 30, 2024
July 22, 2025
August 12, 2015
July 31, 2016
September 30, 2056
June 5, 2059
February 12, 2053
June 10, 2061
May 10, 2022
October 10, 2023
December 26, 2000
February 9, 2006
September 12, 2074
April 30, 2076
May 11, 2001
July 3, 2007
March 27, 2035
May 16, 2035
April 3, 2067
July 13, 2070
May 19, 2031
March 7, 2036
October 13, 2001
February 28, 2004
July 28, 2061
May 5, 2064
January 5, 2043
August 24, 2044
May 7, 2067
June 14, 2074
June 28, 2084
April 9, 2092
November 22, 2036
February 12, 2037
January 20, 2051
July 22, 2056
April 7, 2007
August 3, 2013
October 12, 2032
June 10, 2037
August 18, 2086
August 28, 2089
January 14, 2056
July 22, 2060
September 3, 2053
October 2, 2059
July 20, 2069
June 5, 2071
June 20, 2089
November 22, 2095
November 1, 2007
August 24, 2012
March 21, 2052
May 23, 2058
May 26, 2011
September 23, 2020
January 26, 2077
August 30, 2079
September 6, 2021
March 23, 2027
September 18, 2044
March 25, 2046
October 21, 2065
April 28, 2074
August 14, 2047
August 18, 2050
March 25, 2089
November 11, 2089
July 19, 2068
September 12, 2077
April 14, 2035
May 2, 2042
June 6, 2064
August 24, 2064
February 3, 2027
October 3, 2033
July 30, 2043
November 11, 2043
July 1, 2083
December 1, 2090
September 27, 2045
September 28, 2053
February 18, 2016
November 5, 2018
February 4, 2046
May 13, 2047
August 1, 2043
February 24, 2051
November 9, 2021
January 9, 2025
October 31, 2097
February 4, 2103
January 7, 2046
January 19, 2053
November 6, 2008
March 11, 2011
August 7, 2046
February 17, 2055
November 23, 2093
August 16, 2102
August 26, 2064
October 7, 2065
February 25, 2068
June 15, 2075
January 14, 2053
August 7, 2053
October 2, 2082
April 12, 2088
April 21, 2024
August 25, 2030
July 7, 2071
February 5, 2073
November 4, 2005
July 28, 2013
January 4, 2084
January 9, 2090
May 4, 2034
December 2, 2036
March 13, 2064
December 22, 2064
September 19, 2018
June 20, 2019
December 16, 2025
April 3, 2030
December 24, 2038
July 11, 2040
June 3, 2006
December 22, 2015
September 14, 2014
January 16, 2022
December 12, 2045
June 24, 2046
May 3, 2093
May 28, 2099
February 19, 2077
January 24, 2086
June 28, 2049
November 30, 2049
October 16, 2094
August 17, 2098
February 6, 2079
July 7, 2080
January 22, 2009
February 26, 2009
October 2, 2070
December 26, 2073
April 15, 2077
November 12, 2077
February 25, 2093
November 2, 2102
December 9, 2096
June 3, 2103
November 6, 2095
December 28, 2099
January 27, 2025
November 6, 2030
May 25, 2013
January 30, 2018
December 21, 2015
May 5, 2021
November 17, 2096
April 14, 2100
February 20, 2015
February 18, 2018
November 25, 2009
June 18, 2011
January 15, 2089
October 23, 2098
January 1, 2087
August 26, 2090
June 17, 2050
October 21, 2053
June 21, 2072
July 2, 2073
January 4, 2035
October 12, 2037
June 4, 2060
February 1, 2066
August 4, 2001
February 2, 2004
March 2, 2092
October 28, 2096
September 6, 2066
January 19, 2068
January 13, 2083
September 11, 2092
April 29, 2049
March 30, 2052
August 23, 2039
May 21, 2040
June 14, 2093
August 26, 2093
May 2, 2058
December 22, 2059
AC output:

Code: Select all

Case 1: 1
Case 2: 1
Case 3: 1
Case 4: 0
Case 5: 2
Case 6: 1
Case 7: 1
Case 8: 2
Case 9: 2
Case 10: 1
Case 11: 2
Case 12: 1
Case 13: 1
Case 14: 2
Case 15: 0
Case 16: 2
Case 17: 1
Case 18: 0
Case 19: 1
Case 20: 2
Case 21: 2
Case 22: 0
Case 23: 1
Case 24: 2
Case 25: 1
Case 26: 2
Case 27: 1
Case 28: 2
Case 29: 1
Case 30: 2
Case 31: 0
Case 32: 1
Case 33: 2
Case 34: 2
Case 35: 1
Case 36: 0
Case 37: 1
Case 38: 0
Case 39: 1
Case 40: 1
Case 41: 2
Case 42: 2
Case 43: 2
Case 44: 2
Case 45: 2
Case 46: 1
Case 47: 0
Case 48: 0
Case 49: 1
Case 50: 1
Case 51: 1
Case 52: 1
Case 53: 1
Case 54: 2
Case 55: 0
Case 56: 1
Case 57: 0
Case 58: 1
Case 59: 2
Case 60: 1
Case 61: 2
Case 62: 1
Case 63: 2
Case 64: 2
Case 65: 1
Case 66: 1
Case 67: 1
Case 68: 1
Case 69: 2
Case 70: 0
Case 71: 2
Case 72: 1
Case 73: 2
Case 74: 3
Case 75: 2
Case 76: 1
Case 77: 1
Case 78: 1
Case 79: 2
Case 80: 0
Case 81: 0
Case 82: 1
Case 83: 1
Case 84: 1
Case 85: 0
Case 86: 1
Case 87: 1
Case 88: 1
Case 89: 1
Case 90: 1
Case 91: 1
Case 92: 2
Case 93: 1
Case 94: 0
Case 95: 0
Case 96: 2
Case 97: 1
Case 98: 2
Case 99: 2
Case 100: 1
Case 101: 2
Case 102: 0
Case 103: 2
Case 104: 1
Case 105: 0
Case 106: 1
Case 107: 1
Case 108: 1
Case 109: 2
Case 110: 1
Case 111: 1
Case 112: 2
Case 113: 1
Case 114: 1
Case 115: 1
Case 116: 0
Case 117: 2
Case 118: 2
Case 119: 0
Case 120: 2
Case 121: 2
Case 122: 1
Case 123: 0
Case 124: 1
Case 125: 1
Case 126: 2
Case 127: 1
Case 128: 2
Case 129: 1
Case 130: 1
Case 131: 1
Case 132: 0
Case 133: 1
Case 134: 2
Case 135: 2
Case 136: 0
Case 137: 2
Case 138: 0
Case 139: 0
Case 140: 0
Case 141: 1
Case 142: 2
Case 143: 1
Case 144: 0
Case 145: 0
Case 146: 2
Case 147: 2
Case 148: 2
Case 149: 0
Case 150: 0
Case 151: 0
Case 152: 2
Case 153: 0
Case 154: 1
Case 155: 2
Case 156: 2
Case 157: 0
Case 158: 1
Case 159: 1
Case 160: 2
Case 161: 1
Case 162: 2
Case 163: 0
Case 164: 1
Case 165: 0
Case 166: 0
Case 167: 0
Case 168: 2
Case 169: 2
Case 170: 2
Case 171: 1
Case 172: 2
Case 173: 0
Case 174: 1
Case 175: 3
Case 176: 1
Case 177: 0
Case 178: 0
Case 179: 1
Case 180: 0
Case 181: 2
Case 182: 1
Case 183: 1
Case 184: 2
Case 185: 1
Case 186: 1
Case 187: 2
Case 188: 2
Case 189: 1
Case 190: 1
Case 191: 0
Case 192: 2
Case 193: 1
Case 194: 1
Case 195: 0
Case 196: 1
Case 197: 2
Case 198: 1
Case 199: 2
Case 200: 1
Case 201: 1
Case 202: 1
Case 203: 2
Case 204: 2
Case 205: 1
Case 206: 2
Case 207: 3
Case 208: 1
Case 209: 2
Case 210: 1
Case 211: 1
Case 212: 0
Case 213: 1
Case 214: 1
Case 215: 0
Case 216: 1
Case 217: 2
Case 218: 1
Case 219: 1
Case 220: 2
Case 221: 0
Case 222: 2
Case 223: 2
Case 224: 0
Case 225: 2
Case 226: 0
Case 227: 1
Case 228: 2
Case 229: 2
Case 230: 1
Case 231: 1
Case 232: 2
Case 233: 1
Case 234: 1
Case 235: 2
Case 236: 1
Case 237: 2
Case 238: 2
Case 239: 2
Case 240: 2
Case 241: 1
Case 242: 1
Case 243: 2
Case 244: 2
Case 245: 1
Case 246: 2
Case 247: 0
Case 248: 2
Case 249: 2
Case 250: 1
Case 251: 1
Case 252: 0
Case 253: 2
Case 254: 1
Case 255: 2
Case 256: 2
Case 257: 1
Case 258: 0
Case 259: 2
Case 260: 2
Case 261: 3
Case 262: 0
Case 263: 1
Case 264: 1
Case 265: 1
Case 266: 3
Case 267: 1
Case 268: 2
Case 269: 2
Case 270: 1
Case 271: 2
Case 272: 1
Case 273: 0
Case 274: 1
Case 275: 1
Case 276: 2
Case 277: 2
Case 278: 1
Case 279: 2
Case 280: 2
Case 281: 1
Case 282: 2
Case 283: 0
Case 284: 0
Case 285: 3
Case 286: 2
Case 287: 1
Case 288: 1
Case 289: 0
Case 290: 0
Case 291: 2
Case 292: 1
Case 293: 1
Case 294: 0
Case 295: 2
Case 296: 1
Case 297: 0
Case 298: 2
Case 299: 1
Case 300: 2
Case 301: 1
Case 302: 2
Case 303: 2
Case 304: 0
Case 305: 1
Case 306: 1
Case 307: 1
Case 308: 0
Case 309: 1
Case 310: 2
Case 311: 2
Case 312: 1
Case 313: 0
Case 314: 2
Case 315: 1
Case 316: 0
Case 317: 1
Case 318: 0
Case 319: 2
Case 320: 1
Case 321: 1
Case 322: 1
Case 323: 0
Case 324: 2
Case 325: 1
Case 326: 0
Case 327: 1
Case 328: 2
Case 329: 2
Case 330: 1
Case 331: 0
Case 332: 0
Case 333: 1
Case 334: 2
Case 335: 1
Case 336: 2
Case 337: 1
Case 338: 1
Case 339: 0
Case 340: 1
Case 341: 2
Case 342: 0
Case 343: 2
Case 344: 2
Case 345: 2
Case 346: 1
Case 347: 2
Case 348: 1
Case 349: 3
Case 350: 2
Case 351: 2
Case 352: 1
Case 353: 1
Case 354: 1
Case 355: 1
Case 356: 0
Case 357: 2
Case 358: 0
Case 359: 2
Case 360: 2
Case 361: 0
Case 362: 1
Case 363: 3
Case 364: 2
Case 365: 1
Case 366: 1
Case 367: 1
Case 368: 2
Case 369: 1
Case 370: 1
Case 371: 0
Case 372: 1
Case 373: 2
Case 374: 1
Case 375: 3
Case 376: 0
Case 377: 2
Case 378: 2
Case 379: 1
Case 380: 1
Case 381: 3
Case 382: 2
Case 383: 1
Case 384: 1
Case 385: 1
Case 386: 2
Case 387: 2
Case 388: 2
Case 389: 0
Case 390: 2
Case 391: 1
Case 392: 1
Case 393: 0
Case 394: 2
Case 395: 1
Case 396: 2
Case 397: 2
Case 398: 2
Case 399: 1
Case 400: 1
Case 401: 2
Case 402: 2
Case 403: 1
Case 404: 0
Case 405: 1
Case 406: 0
Case 407: 2
Case 408: 0
Case 409: 1
Case 410: 1
Case 411: 1
Case 412: 0
Case 413: 1
Case 414: 2
Case 415: 0
Case 416: 1
Case 417: 1
Case 418: 2
Case 419: 2
Case 420: 0
Case 421: 2
Case 422: 2
Case 423: 1
Case 424: 1
Case 425: 2
Case 426: 1
Case 427: 0
Case 428: 1
Case 429: 2
Case 430: 1
Case 431: 3
Case 432: 0
Case 433: 1
Case 434: 0
Case 435: 2
Case 436: 1
Case 437: 0
Case 438: 2
Case 439: 2
Case 440: 0
Case 441: 2
Case 442: 0
Case 443: 2
Case 444: 2
Case 445: 1
Case 446: 0
Case 447: 2
Case 448: 1
Case 449: 0
Case 450: 2
Case 451: 0
Case 452: 2
Case 453: 1
Case 454: 0
Case 455: 2
Case 456: 0
Case 457: 2
Case 458: 1
Case 459: 1
Case 460: 2
Case 461: 2
Case 462: 1
Case 463: 0
Case 464: 0
Case 465: 1
Case 466: 1
Case 467: 2
Case 468: 2
Case 469: 0
Case 470: 1
Case 471: 2
Case 472: 0
Case 473: 1
Case 474: 1
Case 475: 0
Case 476: 1
Case 477: 0
Case 478: 1
Case 479: 0
Case 480: 1
Case 481: 1
Case 482: 1
Case 483: 2
Case 484: 0
Case 485: 1
Case 486: 0
Case 487: 2
Case 488: 1
Case 489: 1
Case 490: 0
Case 491: 1
Case 492: 1
Case 493: 0
Case 494: 1
Case 495: 0
Case 496: 3
Case 497: 1
Case 498: 1
Case 499: 0
Case 500: 0
Check input and AC output for thousands of problems on uDebug!

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: Why WA 12439 - February 29??? pls help

Post by uDebug » Fri Apr 25, 2014 8:09 am

brianfry713,

These test cases are amazing. Thanks very much for sharing.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: Why WA 12439 - February 29??? pls help

Post by uDebug » Fri Apr 25, 2014 8:26 am

sadee wrote:pls dont laugh to see my code.
i m new in programming.....
This is really great code for a newbie programmer. Well done!

You're nearly there. Here are the specific test cases your code's failing on. These are from the input brianfry713 shared. If you fix these, you should be all set.

Code: Select all

2
November 29, 2092
September 27, 2100
November 17, 2096
April 14, 2100
AC Output:

Code: Select all

Case 1: 1
Case 2: 0
Your code outputs:

Code: Select all

Case 1: 0
Case 2: -1
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

eldwinpan
New poster
Posts: 2
Joined: Tue May 06, 2014 5:24 am

12439 - February 29

Post by eldwinpan » Tue May 06, 2014 5:32 am

I had tried all of the test and also get right
but why i still get WA;

could someone help me chek it?

Code: Select all


removed after AC


Last edited by eldwinpan on Thu May 08, 2014 4:19 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 12439 - February 29 help!!

Post by brianfry713 » Thu May 08, 2014 12:13 am

Change line 12 to:
char yearfirst[11],yearsecond[11];
Check input and AC output for thousands of problems on uDebug!

eldwinpan
New poster
Posts: 2
Joined: Tue May 06, 2014 5:24 am

Re: 12439 - February 29 help!!

Post by eldwinpan » Thu May 08, 2014 4:18 am

brianfry713,

Thanks you, already got AC :) :)

Tarango_Flash7
New poster
Posts: 5
Joined: Mon Jan 26, 2015 1:31 am

Re: 12439 - January 26,2015

Post by Tarango_Flash7 » Mon Jan 26, 2015 1:40 am

Hello,why isn't my code is being accepted???I checked almost all the inputs available here and all of them match my output.Then why i'm still getting WA???Please someone check my code :(

Code: Select all

#include <iostream>
#include <cstring>
#include <stdio.h>
#include <cmath>
#include <sstream>
using namespace std;

int d1,Y1,d2,y2,start400,end4,end100,end400;
int div4,div100,div400,start4,start100;
string m1,m2,part;

int getInt(string s){
    int num = 0;
    stringstream ss(s);
    ss >> num;
    return num;
}

int calculate(){
    int ans = 0;
    start4 = start100 = start400 = Y1;
    end4 = end100 = end400 = y2;
    div4 = div100 = div400 = 0;
    while(start4%4!=0) start4++;
    while(end4%4!=0) end4--;

    if((y2-Y1)<10){
        for(int yr = Y1;yr<=y2;yr++){
            if(yr%4 == 0){
                if(yr%100 == 0 && yr%400 == 0) ans++;
                else if(yr%100 != 0 ) ans++;
            }
        }
    }else{
        while(start100%100!=0) start100++;
        while(end100%100!=0) end100--;
        while(start400%400!=0) start400++;
        while(end400%400!=0) end400--;
        div4 = (end4-start4)/4;
        if(start100 == end100){
            if(start100%400 == 0) div100 = 1;
        }else if(start100<=y2){
            div100 = (end100-start100)/100;
        }

        if(start400 == end400){
            if(start400%400 != 0) ans--;
        }else if(start400<=y2){
            div400 = (end400-start400)/400;
        }
        ans = div4+div400-div100+1;
    }
    if(Y1 == start4){
        if(m1 != "January" && m1!="February") ans--;
    }
    if(y2 == end4){
        if(m2 == "January") ans--;
        if(m2 == "February" && d2!=29) ans--;
    }
    return max(ans,0);
}

int main(){
    int nCase;
    cin>>nCase;
    for(int cs = 1;cs<=nCase;cs++){
        cin>>m1>>part>>Y1;
        part = part.substr(0,part.length()-1);
        d1 = getInt(part);
        cin>>m2>>part>>y2;
        part = part.substr(0,part.length()-1);
        d2 = getInt(part);
        cout<<"Case "<<cs<<": "<<calculate()<<endl;
    }
    return 0;
}
Last edited by brianfry713 on Tue Jan 27, 2015 1:06 am, edited 1 time in total.
Reason: Added code blocks

Tarango_Flash7
New poster
Posts: 5
Joined: Mon Jan 26, 2015 1:31 am

UVa 12439 February 29

Post by Tarango_Flash7 » Mon Jan 26, 2015 1:46 am

Hello,why isn't my code is being accepted???I checked almost all the inputs available here and all of them match my output.Then why i am still getting WA???Please someone check my code :(

Code: Select all

#include <iostream>
#include <cstring>
#include <stdio.h>
#include <cmath>
#include <sstream>
using namespace std;

int d1,Y1,d2,y2,start400,end4,end100,end400;
int div4,div100,div400,start4,start100;
string m1,m2,part;

int getInt(string s){
    int num = 0;
    stringstream ss(s);
    ss >> num;
    return num;
}

int calculate(){
    int ans = 0;
    start4 = start100 = start400 = Y1;
    end4 = end100 = end400 = y2;
    div4 = div100 = div400 = 0;
    while(start4%4!=0) start4++;
    while(end4%4!=0) end4--;

    if((y2-Y1)<10){
        for(int yr = Y1;yr<=y2;yr++){
            if(yr%4 == 0){
                if(yr%100 == 0 && yr%400 == 0) ans++;
                else if(yr%100 != 0 ) ans++;
            }
        }
    }else{
        while(start100%100!=0) start100++;
        while(end100%100!=0) end100--;
        while(start400%400!=0) start400++;
        while(end400%400!=0) end400--;

        div4 = (end4-start4)/4;
        if(start100 == end100){
            if(start100%400 == 0) div100 = 1;
        }else if(start100<=y2){
            div100 = (end100-start100)/100;
        }

        if(start400 == end400){
            if(start400%400 != 0) ans--;
        }else if(start400<=y2){
            div400 = (end400-start400)/400;
        }
        ans = div4+div400-div100+1;
    }
    if(Y1 == start4){
        if(m1 != "January" && m1!="February") ans--;
    }
    if(y2 == end4){
        if(m2 == "January") ans--;
        if(m2 == "February" && d2!=29) ans--;
    }
    return max(ans,0);
}

int main(){
    int nCase;
    cin>>nCase;
    for(int cs = 1;cs<=nCase;cs++){
        cin>>m1>>part>>Y1;
        part = part.substr(0,part.length()-1);
        d1 = getInt(part);
        cin>>m2>>part>>y2;
        part = part.substr(0,part.length()-1);
        d2 = getInt(part);
        cout<<"Case "<<cs<<": "<<calculate()<<endl;
    }
    return 0;
}
Last edited by brianfry713 on Tue Jan 27, 2015 1:05 am, edited 1 time in total.
Reason: Added code blocks

Post Reply

Return to “Volume 124 (12400-12499)”