10070 - Leap Year or Not Leap Year and …

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

Moderator: Board moderators

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

Postby Crocodile_009 » Thu Mar 08, 2012 8:16 am

i can't understand why my code gets WA :(
here is my code:

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

printf("This is leap year.\n");
if(year%15==0){
printf("This is huluculu festival year.\n");
if(year%55==0){
printf("This is buluculu festival year.\n");
}
}
}
else if(year%15==0){
printf("This is huluculu festival year.\n");
}
else if(year%55==0&&year%100!=0){
printf("This is buluculu festival year.\n");
}
else
printf("This is an ordinary year.\n");

}
return 0;
}
Crocodile_009
New poster
 
Posts: 4
Joined: Thu Mar 08, 2012 8:11 am

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

Postby brianfry713 » Thu Mar 08, 2012 11:44 pm

The input may be too large to fit into an int.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

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

Postby mahade hasan » Fri May 25, 2012 10:40 am

cut>>>>>
Last edited by mahade hasan on Thu Jun 07, 2012 4:54 am, edited 1 time in total.
we r surrounded by happiness
need eyes to feel it!
User avatar
mahade hasan
Learning poster
 
Posts: 63
Joined: Thu Dec 15, 2011 3:08 pm

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

Postby mahade hasan » Tue May 29, 2012 2:00 pm

cut
Last edited by mahade hasan on Mon Jun 11, 2012 7:10 pm, edited 2 times in total.
we r surrounded by happiness
need eyes to feel it!
User avatar
mahade hasan
Learning poster
 
Posts: 63
Joined: Thu Dec 15, 2011 3:08 pm

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

Postby brianfry713 » Fri Jun 01, 2012 1:16 am

Maybe year is longer than 10000 digits.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

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

Postby mahade hasan » Tue Jun 05, 2012 7:26 pm

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!
User avatar
mahade hasan
Learning poster
 
Posts: 63
Joined: Thu Dec 15, 2011 3:08 pm

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

Postby brianfry713 » Tue Jun 05, 2012 9:16 pm

Post your updated code.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

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

Postby mahade hasan » Mon Jun 11, 2012 7:10 pm

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!
User avatar
mahade hasan
Learning poster
 
Posts: 63
Joined: Thu Dec 15, 2011 3:08 pm

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

Postby brianfry713 » Tue Jun 12, 2012 12:11 am

Bulukulu festival (Happens on years divisible by 55 provided that is also a leap year)
16555 is an ordinary year.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

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

Postby brianfry713 » Tue Jun 12, 2012 12:12 am

My AC code assumes each line has a max of 1000000 characters.
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

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

Postby mahade hasan » Wed Jun 13, 2012 7:28 am

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!
User avatar
mahade hasan
Learning poster
 
Posts: 63
Joined: Thu Dec 15, 2011 3:08 pm

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

Postby mathgirl » Fri Jun 15, 2012 2:22 pm

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;
}
mathgirl
New poster
 
Posts: 36
Joined: Tue Apr 24, 2012 6:20 pm

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

Postby brianfry713 » Fri Jun 15, 2012 9:08 pm

"This is leap year.", not "This is a leap year."
brianfry713
Guru
 
Posts: 1771
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

10070 - Leap Year or Not Leap Year and …

Postby sonjbond » Fri Jul 06, 2012 3:16 pm

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[i]=y[i]-48;
a4=(a4*10+y[i])%4;
a15=(a15*10+y[i])%15;
a55=(a55*10+y[i])%55;
a100=(a100*10+y[i])%100;
a400=(a400*10+y[i])%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: 18
Joined: Wed Jul 04, 2012 10:30 pm

10070 - Leap Year WA but y ???

Postby sonjbond » Mon Jul 09, 2012 4:55 am

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[i]=y[i]-48;
a4=(a4*10+y[i])%4;
a15=(a15*10+y[i])%15;
a55=(a55*10+y[i])%55;
a100=(a100*10+y[i])%100;
a400=(a400*10+y[i])%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 ....
sonjbond
New poster
 
Posts: 18
Joined: Wed Jul 04, 2012 10:30 pm

PreviousNext

Return to Volume C

Who is online

Users browsing this forum: No registered users and 1 guest