10070 - Leap Year or Not Leap Year and ...

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

Moderator: Board moderators

ijabir
New poster
Posts: 3
Joined: Thu Sep 26, 2013 5:42 pm

Re: Getting WA - UVA 10070 -Leap Year or Not Leap Year and …

Post by ijabir » Sat Oct 05, 2013 1:13 am

Got AC... :)
thank you brianfry713... :)

woaraka92
New poster
Posts: 9
Joined: Sun Oct 20, 2013 6:50 pm

UVA 10070

Post by woaraka92 » Sun Oct 20, 2013 11:23 pm

whats wrong??

#include<stdio.h>
#include<string.h>

int main()
{
char a[100000];
int i,y4,y15,y55,y100,y400;
while(scanf("%s",a)==1){
y4=0;y15=0;y55=0;y100=0;y400=0;

for(i=0;a!='\0';i++){
y4=y4*10+a-48; y4=y4%4;
y15=y15*10+a-48; y15=y15%15;
y55=y55*10+a-48; y55=y55%55;
y100=y100*10+a-48; y100=y100%100;
y400=y400*10+a-48; y400=y400%400;
}
printf("\n");

if((y4==0&&y100!=0) || (y400==0) || (y15==0)||(y55==0)){
if((y4==0&&y100!=0) || (y400==0)){
printf("This is leap year.\n");
if(y55==0)
printf("This is bulukulu festival year.\n");
}
if(y15==0)
printf("This is huluculu festival year.\n");
}
else
printf("This is an ordinary year.\n");
}
return 0;
}

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

Re: UVA 10070

Post by brianfry713 » Mon Oct 21, 2013 9:29 pm

My AC code assumes a line can be 1000000 digits long.
Check input and AC output for thousands of problems on uDebug!

woaraka92
New poster
Posts: 9
Joined: Sun Oct 20, 2013 6:50 pm

Re: UVA 10070

Post by woaraka92 » Tue Oct 22, 2013 4:09 pm

Ok char a[1000000];
But still wrong answer brianfry713.

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

Re: UVA 10070

Post by brianfry713 » Tue Oct 22, 2013 10:02 pm

Don't print a blank line at the start of the output.
Check input and AC output for thousands of problems on uDebug!

woaraka92
New poster
Posts: 9
Joined: Sun Oct 20, 2013 6:50 pm

Re: UVA 10070

Post by woaraka92 » Wed Oct 23, 2013 8:43 pm

Still wrong Answer brianfry713....

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

Re: UVA 10070

Post by brianfry713 » Thu Oct 24, 2013 8:49 pm

Post your updated code.
Check input and AC output for thousands of problems on uDebug!

woaraka92
New poster
Posts: 9
Joined: Sun Oct 20, 2013 6:50 pm

Re: UVA 10070

Post by woaraka92 » Sat Oct 26, 2013 8:42 pm

#include<stdio.h>
#include<string.h>

int main()
{
char a[1000000];
int i,y4,y15,y55,y100,y400,j=0;
while(scanf("%s",a)==1){
y4=0;y15=0;y55=0;y100=0;y400=0;
if(j!=0)
printf("\n");
j=1;
for(i=0;a!='\0';i++){
y4=y4*10+a-48; y4=y4%4;
y15=y15*10+a-48; y15=y15%15;
y55=y55*10+a-48; y55=y55%55;
y100=y100*10+a-48; y100=y100%100;
y400=y400*10+a-48; y400=y400%400;
}

if((y4==0&&y100!=0) || (y400==0) || (y15==0)||(y55==0)){
if((y4==0&&y100!=0) || (y400==0)){
printf("This is leap year.\n");
if(y55==0)
printf("This is bulukulu festival year.\n");
}
if(y15==0)
printf("This is huluculu festival year.\n");
}
else
printf("This is an ordinary year.\n");
}
return 0;
}

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

Re: UVA 10070

Post by brianfry713 » Mon Oct 28, 2013 8:01 pm

Try input: 16555 output should be: This is an ordinary year.
Check input and AC output for thousands of problems on uDebug!

vaevince
New poster
Posts: 2
Joined: Fri Dec 06, 2013 9:48 am

Re: UVA 10070

Post by vaevince » Fri Dec 06, 2013 9:52 am

brianfry713 ....

IUNemo
New poster
Posts: 1
Joined: Sat Dec 07, 2013 1:14 pm

Re: UVA 10070

Post by IUNemo » Sat Dec 07, 2013 1:19 pm

try 22055
This is an ordinary year.

hoimo
New poster
Posts: 18
Joined: Sun Sep 23, 2012 3:43 am

Re: 10070 - Leap Year or Not Leap Year and ...

Post by hoimo » Sun Dec 15, 2013 4:13 am

what's the problem with my code?
code deleted.
plz help.
Last edited by hoimo on Tue Jan 07, 2014 10:46 pm, edited 1 time in total.

hoimo
New poster
Posts: 18
Joined: Sun Sep 23, 2012 3:43 am

Re: UVA 10070

Post by hoimo » Mon Dec 16, 2013 3:51 am

My code gives right answer for every input given here.
but still WA.
Plz help. thanx in advance. :roll:

hoimo
New poster
Posts: 18
Joined: Sun Sep 23, 2012 3:43 am

Re: UVA 10070

Post by hoimo » Mon Dec 16, 2013 4:05 am

here is my code.

Code: Select all

#include<stdio.h>
#include<string.h>
char yearch[100000000];
int yearint[100000000];

int main()
{
    int hulu, bulu, flg, line=0, add, temp, diff;
    int d3, d4, d5, d11, d55;
    int i, len, frst, lst, lstp;

    while( scanf("%s",yearch) != EOF )
    {
        d5=1;
        hulu=bulu=flg=0;

        if(line)
        printf("\n");
        line=1;

        len = strlen(yearch);
        lstp=len-1;
        lst=frst=0;
        for( i=len-1;i>=0;i-- )
        {
            yearint[i]=yearch[i]-'0';
            if( i==lstp ) {
                lst=lst+yearint[i];
                lstp=lstp-2;
            }
            else {
                frst=frst+yearint[i];
            }
        }

        add = frst+lst;
        diff = lst-frst;

        d3=add%3;

        temp = yearint[len-1]+yearint[len-2]*10;
        d4 = temp%4;

        if( yearint[len-1]==0 || yearint[len-1]==5 )
            d5=0;

        d11 = diff%11;

        if( d3==0 && d5==0 ) hulu=1;

        if( d5==0 && d11==0 ) d55=0;
        else d55=1;


        if( yearint[len-1]=='0' && yearint[len-2]=='0' ) {
            if( d4 == 0 ) {
                flg++;
                printf( "This is leap year.\n" );
                if( d55==0 )
                    bulu=1;
            }
        }
        else {
            if( d4==0 ) {
                flg++;
                printf( "This is leap year.\n" );
                if( d55==0 )
                    bulu=1;
            }
        }

        if( hulu==1 ) {
            flg++;
            printf( "This is huluculu festival year.\n" );
        }
        if( bulu==1 ) {
            flg++;
            printf( "This is bulukulu festival year.\n" );
        }
        if( flg==0 )
            printf("This is an ordinary year.\n");
    }
}

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

Re: 10070 - Leap Year or Not Leap Year and ...

Post by brianfry713 » Tue Dec 17, 2013 11:07 pm

You're printing extra blank lines.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 100 (10000-10099)”