Page 13 of 16

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

Posted: Sat Oct 05, 2013 1:13 am
by ijabir
Got AC... :)
thank you brianfry713... :)

UVA 10070

Posted: Sun Oct 20, 2013 11:23 pm
by woaraka92
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;
}

Re: UVA 10070

Posted: Mon Oct 21, 2013 9:29 pm
by brianfry713
My AC code assumes a line can be 1000000 digits long.

Re: UVA 10070

Posted: Tue Oct 22, 2013 4:09 pm
by woaraka92
Ok char a[1000000];
But still wrong answer brianfry713.

Re: UVA 10070

Posted: Tue Oct 22, 2013 10:02 pm
by brianfry713
Don't print a blank line at the start of the output.

Re: UVA 10070

Posted: Wed Oct 23, 2013 8:43 pm
by woaraka92
Still wrong Answer brianfry713....

Re: UVA 10070

Posted: Thu Oct 24, 2013 8:49 pm
by brianfry713
Post your updated code.

Re: UVA 10070

Posted: Sat Oct 26, 2013 8:42 pm
by woaraka92
#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;
}

Re: UVA 10070

Posted: Mon Oct 28, 2013 8:01 pm
by brianfry713
Try input: 16555 output should be: This is an ordinary year.

Re: UVA 10070

Posted: Fri Dec 06, 2013 9:52 am
by vaevince
brianfry713 ....

Re: UVA 10070

Posted: Sat Dec 07, 2013 1:19 pm
by IUNemo
try 22055
This is an ordinary year.

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

Posted: Sun Dec 15, 2013 4:13 am
by hoimo
what's the problem with my code?
code deleted.
plz help.

Re: UVA 10070

Posted: Mon Dec 16, 2013 3:51 am
by hoimo
My code gives right answer for every input given here.
but still WA.
Plz help. thanx in advance. :roll:

Re: UVA 10070

Posted: Mon Dec 16, 2013 4:05 am
by hoimo
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");
    }
}

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

Posted: Tue Dec 17, 2013 11:07 pm
by brianfry713
You're printing extra blank lines.