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

Oronno
New poster
Posts: 21
Joined: Sun Jul 09, 2006 1:42 pm
Location: Dhaka
Contact:
Ohh...I really do a silly mistake. Its only the spelling mistake of "bulukulu" >> "buluculu"!
Okk......thanks everyone for helping.
I like programming but i am so lazy to do it...
mnthk
New poster
Posts: 3
Joined: Mon Mar 12, 2007 7:42 pm
Location: Bangladesh
Contact:

### 10070

Hey!

Use string to input data .... Born to be a programmer!
mnthk
New poster
Posts: 3
Joined: Mon Mar 12, 2007 7:42 pm
Location: Bangladesh
Contact:

### 10070

Hey!

Use string to input data .... Born to be a programmer!
safayat rahaman
New poster
Posts: 2
Joined: Sun Jul 29, 2007 7:09 am
Location: DHAKA
why runtime error?please help me.here is my code

Code: Select all

``````#include<stdio.h>
#include<string.h>
main()
{
char year;
long a,b,c,d,e,l,rest,flag,sum,flag4,flag11,ten;
long arr;
while((l=strlen(gets(year)))>0)
{
rest=0;
flag=0;
flag4=0;
flag11=0;
for(a=0;a<=l-1;a++)
{rest=rest*10+(year[a]-48);
rest=rest%11;
}
if(rest==0)
flag11=1;
if(l<4)
{rest=0;ten=1;
for(a=l-1;a>=0;a--)
{
rest=(year[a]-48)*ten+rest;
ten=ten*10;
}
arr=year[l-1]-48;
if(rest%4==0)
if(rest%100!=0^rest%400==0)

flag4=1;
}
else
{
for(a=1;a<=4;a++)
{arr[a]=year[l-a]-48;}
if(arr==0&&arr==0)
{
if((arr+arr*10)%4==0)
flag4=1;
}
else
if((arr+arr*10)%4==0)
flag4=1;
}
if(flag4==1)
{printf("This is leap year.\n");flag=1;}

if(arr==0^arr==5)
{
sum=0;
for(a=0;a<=l-1;a++)
sum=sum+year[a]-48;
if(sum%3==0)
{printf("This is huluculu festival year.\n");flag=1;}
if(flag11==1)
{printf("This is buluculu festival year.\n");flag=1;}
}
if(flag==0)
printf("This an ordinary year.\n");
}
}
[code]``````
bhuwan.chopra
New poster
Posts: 3
Joined: Sun Aug 05, 2007 10:58 pm

### Keep on getting WA - 10070 :(

I tried the TC's mentioned in this thread and other threads. They seem to be fine. I keep on getting WA. Also i have taken care of long length numbers.

Code: Select all

``````# include <iostream>
# include <string>

using namespace std;
string str;
bool mod4(string str)
{
int l = str.size();
int no = (str[l-2]-'0')*10 + (str[l-1]-'0');
return (no%4==0);
}

bool mod100()
{
int l = str.size();
int no = (str[l-2]-'0')*10 + (str[l-1]-'0');
return (no==0);
}

bool mod400()
{
int l = str.size();
return ( mod100() && mod4(str.substr(0,l-2)));
}

bool mod3()
{
int sum = 0;
for(int i=0;str[i];i++)
sum+=(str[i]-'0');
return (sum%3==0);
}

bool mod5()
{
int l = str.size();
return (str[l-1]=='0'||str[l-1]=='5');
}

bool mod11()
{
int sum = 0,pow=1;
for(int i=0;str[i];i++,pow*=-1)
sum+=(pow*(str[i]-'0'));
return (sum%11==0);
}

bool mod15()
{
return (mod3() && mod5());
}

bool mod55()
{
return (mod5() && mod11());
}

int main()
{
int ca=1;
while(cin>>str)
{
if(ca!=1)
cout<<endl;
ca++;
bool l = false;
bool p = false;
if(mod400()||(mod4(str)&&!mod100()))
{
cout<<"This is leap year."<<endl;
l=true;
p=true;
}
if(mod15())
{
cout<<"This is huluculu festival year."<<endl;
p=true;
}
if(l&&mod55())
{
cout<<"This is bulukulu festival year."<<endl;
p=true;
}
if(!p)
cout<<"This is an ordinary year."<<endl;
}
return 0;
}
``````
Thanks,
Bhuwan
Bitta
New poster
Posts: 4
Joined: Fri Jan 25, 2008 7:04 pm
Location: Dhaka,Bangladesh
Contact:
I am getting WA.Pls help!!!Here is my code...

Code: Select all

``````#include<stdio.h>
#include<string.h>
#define max 10000

int main (void)

{	char a[max];
int i,sum1,sum2,p,q,r,s,e,f,g;

while(scanf("%s",&a)==1)

{	p=strlen(a)-1;
sum1=0;
sum2=0;
q=0;
r=0;
s=0;
e=0;
f=0;
g=0;

for(i=0;i<=p;i+=2)
{	sum1+=(a[i]-'0');
}

for(i=1;i<=p;i+=2)
{	sum2+=(a[i]-'0');
}

if(((a[p]-'0')+((a[p-1]-'0')*10))%4==0)
{	e=1;
}

if(a[p]=='0' || a[p-1]=='0')
{	f=1;
}

if(a[p]=='0' && a[p-1]=='0' && ((a[p-2]-'0')+((a[p-3]-'0')*10))%4==0)
{	g=1;
}

if((e==1 && f!=1)|| g==1)
{	printf("This is leap year.\n");
q=1;
}

if((a[p]=='5'||a[p]=='0') && ((sum1+sum2)%3==0))
{	printf("This is hulukulu festival year.\n");
r=1;
}
if((a[p]=='5'||a[p]=='0') && ((sum1-sum2)%11==0) && q==1)
{	printf("This is bulukulu festival year.\n");
s=1;
}

if(q==0 && r==0 && s==0)
{	printf("This is an ordinary year.\n");
}

printf("\n");
}

return 0;
}``````
[Edited by : Jan] Use code tags
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Check your spelling carefully and try the case.

Input:

Code: Select all

``4248035245857302861304475122262852382232831183377907185400973044372526725256648804647567360``
Output:

Code: Select all

``````This is leap year.
This is huluculu festival year.
This is bulukulu festival year.``````
Hope these help.
amit_chauhan
New poster
Posts: 2
Joined: Thu Apr 10, 2008 9:59 am

### Re: Problem 10070 leap year...

Hi Friends i am getting run time error. Plz help me..........

Code

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

int main()
{
char year;
int flag=0,i=0;
int mod4,mod100,mod400,mod15,mod55;

while (1)
{

if (fgets(year,sizeof(year),stdin)==NULL) break;

mod4=mod100=mod400=mod15=mod55=0;

if(flag==0) flag=1;
else printf("\n");

for (i=0;i<strlen(year)-1;i++)
{
mod4=(mod4*10+year-'0')%4;
mod100=(mod100*10+year-'0')%100;
mod400=(mod400*10+year-'0')%400;
mod15=(mod15*10+year-'0')%15;
mod55=(mod55*10+year-'0')%55;
}

if((mod4==0 && mod100!=0)||( mod400==0))
{
printf("This is leap year.\n");
if(mod15==0)
printf("This is huluculu festival year.\n");
if(mod55==0)
printf("This is bulukulu festival year.\n");
}
else
{
if(mod15==0)
printf("This is huluculu festival year.\n");
else
printf("This is an ordinary year.\n");
}

}

return 0;
}
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

### Re: Problem 10070 leap year...

If you want to declare a big array, make it global rather than local.
Ami ekhono shopno dekhi...
HomePage
amit_chauhan
New poster
Posts: 2
Joined: Thu Apr 10, 2008 9:59 am

### Re: Problem 10070 leap year...

@Jan

Thanks a lots Bro I got accepted...........
scorpio
New poster
Posts: 2
Joined: Fri Jun 06, 2008 11:48 am
Location: Dhaka,Bangladesh
Contact:

### Re: 10070 - Leap Year or Not Leap Year and …

its an easy prob. but i keep getting WA in it.here is my code:

Code: Select all

``````#include<stdio.h>
int main()
{
char a;
int b,c,d,e,f,x,i,y,p,q;
while(gets(a))
{
b=c=d=e=f=p=q=x=0;
for(i=0;a[i];i++)
{
b=(b*10+a[i]-48)%4;
c=(c*10+a[i]-48)%100;
d=(d*10+a[i]-48)%400;
e=(e*10+a[i]-48)%15;
f=(f*10+a[i]-48)%55;
}
if(y==1)
printf("\n");
if((b==0&&c!=0)||d==0)
{
x=y=1;
printf("This is leap year.\n");
}
if(e==0)
{
y=p=1;
printf("This is huluculu festival year.\n");
}
if(x==1&&f==0)
{
y=q=1;
printf("This is bulukulu festival year.\n");
}
if(x==0&&p==0&&q==0)
{
y=1;
printf("This is an ordinary year.\n");
}
}
return 0;
}
``````
can anyone give some sample I/O..or pls tell me where i missing thingz...Thanx in advance lnr
Experienced poster
Posts: 142
Joined: Sat Jun 30, 2007 2:52 pm
Location: Dhaka,Bangladesh

### Re: runtime error

Runtime error occurs when your code fails to run for an input in running time.
It may happen when
1.the array size is small
2.index out of range for an array
3.divide by zero
and others .....
eendro
New poster
Posts: 1
Joined: Sun May 09, 2010 11:30 pm

### Re: 10070 - Leap Year or Not Leap Year and …

# include<stdio.h>
int main()
{
int y,tmp,h;
while(scanf("%d", &y)==1)
{
h=0;
tmp=0;
if((y%400==0)||(y%100!=0)&&(y%4==0))
{
printf("This is leap year.\n");
tmp=1;
}

if(y%15==0)
{
printf("This is huluculu festival year.\n");
h=1;
}

if((y%55==0)&&(tmp==1))
{
printf("This is buluculu festival year.\n");
}

if((tmp!=1)&&(h!=1))
{
printf("This is an ordinary year.\n");
}
printf("\n");
}
return 0;
}

what is the wrong here?????
iceb3rg
New poster
Posts: 7
Joined: Mon Jul 13, 2009 11:30 am
Location: SUST - CSE
Contact:

### Re:

problem wrote:[c]....
..............
...........
...............

my output
==========

This is Leap year.

This is Leap year.
This is huluculu festival year.

This is huluculu festival year.

This is ordinary year.

This is Leap year.
This is buluculu festival year.

This is ordinary year.

This is Leap year.
This is buluculu festival year.

This is Leap year.
This is huluculu festival year.
This is buluculu festival year.

This is huluculu festival year.

This is Leap year.
This is buluculu festival year.

This is Leap year.

This is ordinary year.

This is ordinary year.

This is ordinary year.

--This is Leap year. //15 th is not match of actual output.
--This is buluculu festival year.

This is ordinary year.

This is Leap year.
This is huluculu festival year.

This is huluculu festival year.

This is Leap year.

This is ordinary year.

This is ordinary year.

This is huluculu festival year.

This is Leap year.
This is huluculu festival year.

This is ordinary year.

This is huluculu festival year.

This is huluculu festival year.

This is huluculu festival year.

This is huluculu festival year.

This is ordinary year.

This is Leap year.

This is Leap year.
This is huluculu festival year.

This is huluculu festival year.

This is ordinary year.

but actual output is::
========================

This is leap year.

This is leap year.
This is huluculu festival year.

This is huluculu festival year.

This is an ordinary year.

This is leap year.
This is bulukulu festival year.

This is an ordinary year.

This is leap year.
This is bulukulu festival year.

This is leap year.
This is huluculu festival year.
This is bulukulu festival year.

This is huluculu festival year.

This is leap year.
This is bulukulu festival year.

This is leap year.

This is an ordinary year.

This is an ordinary year.

This is an ordinary year.

==This is leap year. //NOT MATCH IN MY OUTPUT//

This is an ordinary year.

This is leap year.
This is huluculu festival year.

This is huluculu festival year.

This is leap year.

This is an ordinary year.

This is an ordinary year.

This is huluculu festival year.

This is leap year.
This is huluculu festival year.

This is an ordinary year.

This is huluculu festival year.

This is huluculu festival year.

This is huluculu festival year.

This is huluculu festival year.

This is an ordinary year.

This is leap year.

This is leap year.
This is huluculu festival year.

This is huluculu festival year.

This is an ordinary year.

HELP ME PLZ.
[\c]

Hey dude.....There's a lot of spelling mistake out there...."Leap" should be "leap" and "buluculu" should be "bulukulu" - note the Big L and K here !....That may help ! still a lot to learn & a long long way to go....but I'll keep trying till I have lov 4 it iceb3rg
New poster
Posts: 7
Joined: Mon Jul 13, 2009 11:30 am
Location: SUST - CSE
Contact:

### WA: Any special test cases?

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

char name;
int t;
int save;
int i,ans;
int a=0;

int chk(int t)
{
a=0;
int rem=0;

//scanf ("%d",&t);

int num=0;

for (i=0;name!='\0';i++)
{

while (1)
{
num=num*10;
num+=name-48 ;

if (num==0)
break;

//printf ("# num = %d i = %d\n",num,i);

if (num>=t)
break;
else
{
i++;
if (i>strlen(name)-1)
break;
//num=num*10;
}

}

if (num==0)
{
ans=0;
save[a++]=ans;
//printf ("num = %d ans = %d\n",num,ans);
save[a]='\0';
}
else
{
ans=num/t;

save[a++]=ans;
//printf ("num = %d ans = %d\n",num,ans);
save[a]='\0';

ans=num%t;
num=ans;

if (num!=0 && name[i+1]=='\0')
{
//printf ("Remainder left = %d\n",num);
rem=1;
}
else
rem=0;
}
}

return rem;

}

int main()
{

//freopen("input4uva.txt","r",stdin);

int y=0;

while (scanf ("%s",name)!=EOF)
{
int stat,leap=0,stat2;

if (y==0)
y++;
else
printf ("\n");
//puts(save);

/*
for (int z=0;z<a;z++)
printf ("%d",save[z]);
printf ("\n");
*/
int hul=1,bul=1;

//stat=chk(400);

//if (stat==0)
// leap=1;
//else

// ekhane change

{
stat=chk(4);
stat2=chk(100);
int stat3=chk(400);

if ((stat==0 && stat2==1 )|| stat3==0)
leap=1;
}
//printf ("res %d\n",stat);

int lp=0,fv=0;

if (leap==1)
{
printf ("This is leap year.\n");
lp=1;
}

hul=chk(15);
bul=chk(55);

if (hul==0)
{
printf ("This is huluculu festival year.\n");
fv=1;
}

if (leap==1 && bul==0)
{
printf ("This is bulukulu festival year.\n");
fv=1;
}

if (lp==0 && fv==0)
printf ("This is an ordinary year.\n");

}
return 0;
}

######################################################################################################################
Hi, I am struggling with this problem..can any 1 tell me where am i going wrong....any test cases to put me on track?
still a lot to learn & a long long way to go....but I'll keep trying till I have lov 4 it 