## 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 …

Got AC...
thank you brianfry713...

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

### UVA 10070

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

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

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

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

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 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

#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

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

brianfry713 ....

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

### Re: UVA 10070

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 ...

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

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

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

### Re: UVA 10070

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];
}
}

diff = lst-frst;

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 ...

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