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

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 »

Maybe year is longer than 10000 digits.
Check input and AC output for thousands of problems on uDebug!
mahade hasan
Learning poster
Posts: 87
Joined: Thu Dec 15, 2011 3:08 pm
Location: University of Rajshahi,Bangladesh

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

Post by mahade hasan »

brianfry713 wrote:Maybe year is longer than 10000 digits.
I made it 100000000 but also WAAAAA!!!!!
we r surrounded by happiness
need eyes to feel it!
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 »

Post your updated code.
Check input and AC output for thousands of problems on uDebug!
mahade hasan
Learning poster
Posts: 87
Joined: Thu Dec 15, 2011 3:08 pm
Location: University of Rajshahi,Bangladesh

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

Post by mahade hasan »

cutt.....After AC
Last edited by mahade hasan on Wed Jun 13, 2012 7:27 am, edited 1 time in total.
we r surrounded by happiness
need eyes to feel it!
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 »

Bulukulu festival (Happens on years divisible by 55 provided that is also a leap year)
16555 is an ordinary year.
Check input and AC output for thousands of problems on uDebug!
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 »

My AC code assumes each line has a max of 1000000 characters.
Check input and AC output for thousands of problems on uDebug!
mahade hasan
Learning poster
Posts: 87
Joined: Thu Dec 15, 2011 3:08 pm
Location: University of Rajshahi,Bangladesh

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

Post by mahade hasan »

brianfry713 wrote:Bulukulu festival (Happens on years divisible by 55 provided that is also a leap year)
16555 is an ordinary year.
thanks ......it's work,thanks a lot!!
we r surrounded by happiness
need eyes to feel it!
@ce
Learning poster
Posts: 71
Joined: Mon May 28, 2012 8:46 am
Location: Ranchi, India

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

Post by @ce »

Getting WA...plz help me find the error in my code:-

Code: Select all

Code removed after AC
Last edited by @ce on Mon Jun 25, 2012 10:02 am, edited 2 times in total.
-@ce
mathgirl
New poster
Posts: 36
Joined: Tue Apr 24, 2012 6:20 pm

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

Post by mathgirl »

I checked my output with previous I/O. My prog accepts MAX 1000000 chars. Still WA.

Code: Select all

#include<stdio.h>
#include<cstring>
#define MAX 1000000

int main()
{
	char year[MAX + 10];
	bool first = true;
	while(scanf("%s",year) != EOF)
	{
		bool leap = false, hulu = false, bulu = false;
		int len = strlen(year);
		int a = year[len - 2] - '0';
		a = a * 10 + year[len-1] - '0';
		int b = year[len - 4] - '0';
		b = b * 10 + year[len-3];

		if(a == 0 && b % 4 == 0)
			leap = true;
		else if(a && a % 4 == 0)
			leap = true;

		int sum = 0, altsum = 0;
		for(int i = 0;i < len;i++)
		{
			sum = sum + year[i] - '0';
			if(i % 2 == 0)
				altsum = altsum + year[i] - '0';
			else
				altsum = altsum - year[i] + '0';
		}

		if( (year[len-1] == '0' || year[len-1] == '5') && sum % 3 == 0 )
			hulu = true;

		if(leap && (year[len-1] == '0' || year[len-1] == '5') && altsum % 11 == 0)
			bulu = true;

		if(!first)
			printf("\n");
		first = false;

		if(leap)
			printf("This is a leap year.\n");
		if(hulu)
			printf("This is huluculu festival year.\n");
		if(bulu)
			printf("This is bulukulu festival year.\n");

		if(!leap && !hulu && !bulu)
			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: 10070 - Leap Year or Not Leap Year and ...

Post by brianfry713 »

A line may be longer than 1000 digits. My AC code assumes a line can be 1000000 digits long.
Check input and AC output for thousands of problems on uDebug!
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 »

"This is leap year.", not "This is a leap year."
Check input and AC output for thousands of problems on uDebug!
@ce
Learning poster
Posts: 71
Joined: Mon May 28, 2012 8:46 am
Location: Ranchi, India

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

Post by @ce »

yeah..thanks a lot brianfry for pointing out....i got AC :)
-@ce
sonjbond
New poster
Posts: 19
Joined: Wed Jul 04, 2012 10:30 pm

10070 - Leap Year or Not Leap Year and …

Post by sonjbond »

my code is :

#include<stdio.h>
#include<string.h>
int main()
{
char y[1000000];
while(gets(y))
{
long i,n,a4=0,a15=0,a55=0,a100=0,a400=0;
i=0;
n=strlen(y);
while(i<n)
{
y=y-48;
a4=(a4*10+y)%4;
a15=(a15*10+y)%15;
a55=(a55*10+y)%55;
a100=(a100*10+y)%100;
a400=(a400*10+y)%400;
i++;
}

if((a4==0&&a100!=0)||a400==0)
{
printf("This is leap year.\n");
if(a15==0)
printf("This is huluculu festival year.\n");
if(a55==0)
printf("This is bulukulu festival year.\n");
}
else
{
if(a15==0)
printf("This is huluculu festival year.\n");
else
printf("This is an ordinary year.\n");
}
printf("\n");
}
return 0;
}

getting WA again and again !!! :( plz help meeee ......
sonjbond
New poster
Posts: 19
Joined: Wed Jul 04, 2012 10:30 pm

10070 - Leap Year WA but y ???

Post by sonjbond »

plz help ,,, here's my code :

#include<stdio.h>
#include<string.h>
int main()
{
char y[100];
while(gets(y))
{
int i,n,a4=0,a15=0,a55=0,a100=0,a400=0;
i=0;
n=strlen(y);
while(i<n)
{
y=y-48;
a4=(a4*10+y)%4;
a15=(a15*10+y)%15;
a55=(a55*10+y)%55;
a100=(a100*10+y)%100;
a400=(a400*10+y)%400;
i++;
}
if((a4==0&&a100!=0)||a400==0)
{
printf("This is leap year.\n");
if(a15==0)
printf("This is huluculu festival year.\n");
if(a55==0)
printf("This is bulukulu festival year.\n");
}
else
{
if(a15==0)
printf("This is huluculu festival year.\n");
else
printf("This is an ordinary year.\n");
}
printf("\n");
}
return 0;
}


plz help me ....
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 »

Don't print an extra blank line at the end of the output.
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 100 (10000-10099)”